|
I'm throwing a new SoapException from a web service using the following constructor arguments:
string message,
XmlQualifiedName code,
Exception innerException
When the SoapException is thrown (and then caught by the client), I am accessing the Code property and the value is there as expected.
However, the Message and InnerException properties do not appear to have the values that I expect.
The Message property displays the full stack trace including the SoapException and inner exception. However, I'm passing a message parameter into the custom SoapException of: "MyWebService failed to insert the record." This message is included towards the beginning of the stack trace returned by the property but based on the SoapException constructor parameter name, I would expect that the Message property would have a value of "MyWebService failed to insert the record."
Also, when the custom SoapException is caught by the client, the InnerException property is null, even though I'm passing the inner exception as a third parameter to the constructor of the custom SoapException.
So am I doing something wrong or does .NET not construct custom SoapExceptions quite as expected?
|
|
|
|
|
I am new to looking at WebServices. At any rate, what I am trying to do while learning is say lookup some information from ActiveDirectory and then return a value such as a givenname in the header. I am curious as to how to accomplish this so the value can be grabbed like givenname = Response.Headers.Get("givenname") in the page codebehind.
Or if you know of any tutorials to show how to do this, that would be great also. I have looked but have come up empty handed.
Thanks.
Revolutionary: Disk drives go round and round.
|
|
|
|
|
I am adding an XML file as a cache dependency. I am testing in the Visual Studio debug development environment. Now, while testing each time I change the content of the XML file the key that relies on the file dependency does not get removed from cache. Below is the code:
XMLConfiguration.cs --------------------------------------------------------------
public static XMLConfiguration Load(CacheManager cacheManager)
{
var configuration = new XMLConfiguration();
if (cacheManager.GetCacheItem<xmlconfiguration>(_cacheKey) != null)
{
configuration = cacheManager.GetCacheItem<xmlconfiguration>(_cacheKey);
}
else
{
string path = HttpContext.Current.Server.MapPath("~/App_Data/XMLConfiguration.xml");
var doc = XDocument.Load(path);
configuration = new XMLConfiguration(doc);
string[] dependency = {""};
dependency[0] = HttpContext.Current.Server.MapPath("XMLConfiguration.xml");
CacheDependency cacheDependency = new CacheDependency(dependency);
cacheManager.SetConfigurationItem(_cacheKey, configuration, cacheDependency);
}
return configuration;
}
CacheManager.cs -------------------------------------------------------
public void SetConfigurationItem(string keyName, object configObject, CacheDependency dependency)
{
DateTime dt = DateTime.Now;
object configValue = CacheItem(keyName);
if (configValue == null)
{
HttpRuntime.Cache.Insert(keyName, (object)configObject, dependency, (dt.AddMinutes(1)), Cache.NoSlidingExpiration, CacheItemPriority.Default, null);
}
}
</xmlconfiguration></xmlconfiguration>
Can anyone help?
Thanks,
Steve
|
|
|
|
|
I got it working. The problem was that I was not using ~/App_Data/XMLConfiguration.xml as the parameter to MapPath. I was using XMLConfiguration.xml Sorry for the post.
Thanks,
Steve
|
|
|
|
|
I have a very basic question. I have a webservice with method calls to methods within dlls and within the dlls I have added object caching - not page caching.
My question is: will each user of the webservice have their own cache? Or are these objects that are cached in the same cache for all the calls to the dlls?
|
|
|
|
|
dd314159 wrote: My question is: will each user of the webservice have their own cache? Or are these objects that are cached in the same cache for all the calls to the dlls?
No. There is one cache per process, not by user.
I didn't get any requirements for the signature
|
|
|
|
|
Thanks for the answer - but still one more question. So you are saying that the webservice with multiple dll calls - constitutes one process?
|
|
|
|
|
Any application in ISS (service or website) is part of an application pool.
The application pool runs one .exe. You can see it in the task manager.
The System.Web.HttpContext.Current.Cache is specific to the current HttpContext or application.
What does it matter if all your code is compiled into one .dll or 50 .dlls?
I didn't get any requirements for the signature
|
|
|
|
|
|
I'm really fighting this issue where Firefox is loading my pages twice. Running through the debugging of the pages, my OnInit and Page_Load events are executed twice. This only happens using FireFox, IE7 loads the pages properly. I've been researching the issue and found all the normal "Empty image src" posts and even tried the AutoEventWireup being set to false, and none have resolved my issue. It's causing me all sorts of problems, double emails, double database entries being written, etc. Please can someone just point me in some direction? I would be very grateful.
I'm using VS Team Suite SP1, 3.5 SP1 of the framework and FireFox 3.07. Here is my simple most stripped down test page that the issue is still occurring on.
<![CDATA[<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="WebForm2.aspx.cs" Inherits="RSD.DADS.Web.WebForm2" %>]]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:label id="Label1" runat="server" text="1" xmlns:asp="#unknown"></asp:label>
<br />
<asp:label id="Label2" runat="server" text="2" xmlns:asp="#unknown"></asp:label>
<br />
<asp:label id="Label3" runat="server" text="3" xmlns:asp="#unknown"></asp:label>
<br />
<asp:label id="Label4" runat="server" text="4" xmlns:asp="#unknown"></asp:label>
</div>
</form>
</body>
</html>
And the CodeBehind:
using System;
namespace RSD.DADS.Web
{
public partial class WebForm2 : System.Web.UI.Page
{
override protected void OnInit(EventArgs e)
{
this.Load += new System.EventHandler(this.Page_Load);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillLabel1();
FillLabel3();
FillLabel4();
}
}
private void FillLabel1()
{
Label1.Text = "From FillLabel1()";
FillLabel2();
}
private void FillLabel2()
{
Label2.Text = "From FillLabel2()";
}
private void FillLabel3()
{
Label3.Text = "From FillLabel3()";
}
private void FillLabel4()
{
Label4.Text = "From FillLabel4()";
}
}
}
modified on Wednesday, March 18, 2009 2:52 PM
|
|
|
|
|
Well I was able to stop the page from loading twice in Firefox. All the outputted HTML validated just fine using FireBug, but then just on a whim, I decided to remove the DOCTYPE line.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and page only ran through once. I didn't think that the "XHTML 1.0 Transitional" would have been strict enough to cause this. So I tried using
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
then tried
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
Neither stopped FireFox from loading the page twice. So far the only way that the page is not running through the Page_Load twice, is if I remove the DOCTYPE all together.
Any thoughts as to why this would be happening?
|
|
|
|
|
just remove below code in oninit event and try.....
this.Load += new System.EventHandler(this.Page_Load);
|
|
|
|
|
Out of interest, why did you add the oninit event? That is your problem, cause it runs the oninit event which fires the page_load event, and then the page loads which then executes the Page_loads event again, because it is two different events and not a post back your IsPostBack check will return false causing your fill methods to run twice (Once on the oninit and once on the page_load).
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
The problem occurs with or without the onInit event. The issue happened prior to my adding of the onInit. I added that once I changed my AutoEventWireup property to false, which was a frequently found suggestion. Once it was changed to false, I then had to declare the page_load event or it (page_load) never executed.
Did you happen to take the code and run through debugging it with FireFox 3.0.7? Does it not execute the page twice? The only way that I was able to make the page stop executing the whole page two times was to remove the DOCTYPE declaration.
Thanks for your input.
|
|
|
|
|
I have a strange problem (imho).
I have a gridview and in this gridview it is possible to have DateTime and Decimal objects.
In the database we have stored the format in which these fields should be showed like 'dd MMM yyyy HH:mm' for a DateTime.
But our customer wants to be able to change that formatstring in the database and in the gridview the new choosen formatstring should be applied after a refresh of the grid.
The issue is this.
In the OnRowDataBound event of the grid I call a Method to determine the original datatype of the cellvalue.
I can find that datatype in the DataRowView GetType. And if it is System.DateTime, I can put the value in a datetime object. But then...
How do I know which Cell in the GridView holds this DataRowView value so I could change the TableCell Text property with the value formatted to the formatstring which is found in the database ?
Extra problem:
the dataRowView[0] holds the DataKeyValue for the gridviewrow (needed when selcting or editing).
But tableCell[0] is not always dataRowView[1] because we do not always use all the fields in the dataRowView.
Or is there a better way to solve this?
|
|
|
|
|
I would suggest setting the Date format as a user preference in your application as opposed to allowing the user to update the data in the database. This would be the easiest way to allow this change on your page and would also keep your database from having multiple date values. Here is an article that may assist you in setting up application/user settings.
http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx[^]
Hope this helps.
Matthew Vass
QA Analyst
mvass@hostmysite.com
http://www.hostmysite.com?utm_source=bb[^]
|
|
|
|
|
Hello Matthew,
this is not what I am looking for.
There is only 1 setting for al users. It is not attached to user but to datatype.
Any one else who knows how to find the link between datarowview value and tablecell value and the filling on the fly of the dataformatstring of the gridview?
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Having it fixed
This is the trick
1. Determine for each gridviewcolumn its headertext
2. Determine for each cell in the row.cells if the cell.ContainingField.HeaderText equals the headertext found in the previous gridviewcolumn
3. If the value of an item in the array of the datarowview with (yeah I know it can be buggy) the cell.text value you have found it
Than determine the type of the dataRowView[x] and fill cell.text with the formatstring in the Database.
Anyone a better solution ?
see my code:
public static GridViewRow MaakGridViewRowOp(GridViewRow row)
{
GridView grid = (GridView)row.NamingContainer;
DataRowView dataRow = (DataRowView)row.DataItem;
foreach (DataControlField column in grid.Columns)
{
foreach (DataControlFieldCell cell in row.Cells)
{
if (column.HeaderText.Equals(cell.ContainingField.HeaderText)
&& !String.IsNullOrEmpty(column.HeaderText))
{
for (int celwaarde = 1; celwaarde < dataRow.Row.ItemArray.Length; celwaarde++)
{
if (cell.Text.StartsWith(dataRow[celwaarde].ToString(),
StringComparison.OrdinalIgnoreCase))
{
if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.DateTime")))
{
DateTime datum = Convert.ToDateTime(dataRow[celwaarde]);
cell.Text = datum.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("DatumTijdFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Decimal")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int32")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int16")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int64")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
break;
}
}
}
}
}
return row;
}
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi
I am developing an windows service that sends email notifications to all not activated members and not published users. I tested my email notifications with a sample windows application but the same notifications are failing in my service. But I put all of the dlls in the same directory as my service exe file.
Here is the piece that fails:
SMPTServer = this.gs.SMTPServer;
if (userEmail != "" && userEmail != null)
{
//Send Email Notification
doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message(); -- it fails here, but this works with my windows test application.
}
The service logged with "Object reference not set to an instance of an object."
Can any give me ideas, how can I solve this.
modified on Wednesday, March 18, 2009 12:47 PM
|
|
|
|
|
You might get the NUll reference because you first check if userEmail = ""
It is more wise to create the next IF
if (null != userEmail && !userEmail.Equals(String.Empty))
|
|
|
|
|
Hi
I checked it, it was not problem in the line of code that I posted but its the problem with
doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message();
This is strange. For me the following line of code is working but the above one is not working:
doXtop.Framework.Messaging.Message.SendEmail("info@doXtop.com", userEmail, subject, message, SMTPServer);
|
|
|
|
|
can/will you show the code of the messaging class?
|
|
|
|
|
Here is the code of my messaging class:
public class Message : IDisposable
{
public Hashtable HtEmails;
public HttpContext Context;
public bool ThreadExecution = false;
public string From;
public string Subject;
public string SmtpClient;
public string Body;
public string EmailProvider;
public string Username;
public string FullName;
public string ActivationMessage;
public Guid UserId;
public GlobalSettings gs;
public Uri Url;
public string ApplicationPath;
public enum Box
{
Inbox,
Outbox
}
DataAccess _da;
DataSource _ds;
public Message()
{
_da = new DataAccess();
_ds = new DataSource(_da);
ConfigurationProvider cp = new ConfigurationProvider();
gs = cp.GlobalSettings;
}
public bool InsertMessage(string from, string to, string subject, string body, string senderIPAddress)
{
try
{
SqlParameter[] _params = {
new SqlParameter("@MessageId", Guid.NewGuid()),
new SqlParameter("@From", from),
new SqlParameter("@To", to),
new SqlParameter("@Subject", subject),
new SqlParameter("@Body", body),
new SqlParameter("@SenderIPAddress", senderIPAddress)
};
_ds.ExecuteNonQueryProcedureProxy("InsertMessage", _params);
return true;
}
catch (Exception e)
{
EventLog.WriteEntry("WideDocs", e.ToString(), EventLogEntryType.Error);
return false;
}
}
}
|
|
|
|
|
I believe your problem is this:
public Hashtable HtEmails;
public HttpContext Context;
public bool ThreadExecution = false;
public string From;
public string Subject;
public string SmtpClient;
public string Body;
public string EmailProvider;
public string Username;
public string FullName;
public string ActivationMessage;
public Guid UserId;
public GlobalSettings gs;
public Uri Url;
public string ApplicationPath;
they are mostly null. Havent you forget the { get; set; } to use them as properties?
You do not use any of these publics in your class and you cannot set them from outside.
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi All,
I have a mysql database. I have a web portal in php where users can update personal information which is added and stored in the database. Im building another web app in asp .net which will feed from the same database.
Is there anyway of 'listening' for when updates occur in the database efficently from my asp .net web app?
Im not sure what the best approach is.
Any suggestions much appreciated.
Thanks
Mike
|
|
|
|