Reputation: 37
my problem is User.Identity.Name or Request.Url.AbsoluteUri in exception handling is empty when exception email to me.
this is Application_Code:
void Application_Error(object sender, EventArgs e)
{
Server.Transfer("~/errors/default.aspx");
}
and this is default.aspx code:
protected void Page_Load(object sender, EventArgs e)
{
if (Server.GetLastError() == null)
return;
Exception ex = Server.GetLastError().GetBaseException();
if (ex == null)
return;
string message = string.Format("User: ", User.Identity.Name);
message += Environment.NewLine;
message += string.Format("AbsoluteUri: ", Request.Url.AbsoluteUri);
message += Environment.NewLine;
message += string.Format("Form: ", Request.Form.ToString());
message += Environment.NewLine;
message += string.Format("QueryString: ", Request.QueryString.ToString());
message += Environment.NewLine;
but i receive email like this (this is header without full exception content):
User:
AbsoluteUri:
Form:
QueryString:
Browser Capabilities:
Type = IE8
Name = IE
Version = 8.0
Platform = WinXP
Is Crawler = False
Supports Cookies = True
Supports JavaScript = 1.2
why username and request url is emty?
this problem is exist when i replace transfer with redirect or i don't use both.
tanx
Upvotes: 0
Views: 816
Reputation: 66641
You do not have set the string.Format in the correct way
Try this.
string.Format("AbsoluteUri: {0}", Request.Url.AbsoluteUri);
How ever I suggest to use StringBuilder for this code.
Upvotes: 2