Custom Errors Only Working With File Name?
Dec 3, 2010[Code]....
Custom errors only working with file name
[Code]....
Custom errors only working with file name
I'm trying to set up custom errors for asp.net in webconfig/global.asax on Server 2003, IIS 6. Got it working find for .aspx pages but not for any htm or html pages. So I found the article describing how to open IIS manager, click configuration, copy path for .aspx extension and add one for .htm Did that.
Restarted website: Now I get the blank white page explaining there's a problem but not the 404 page not found
Restarted web services: same thing
For some reason the Custom Errors for 404 pages are not working on my production server, but they work fine on development. Instead of going to the custom 404.aspx page, it goes to the ugly IIS 404 page.
Here is my Custom Errors protion of my web.config:
[Code]....
I changed the defaultRedirect to also go to my 404.aspx page just to make sure I was catching everything, but still it does't work. I know I could change the IIS 404 error to also point to my 404.aspx page, but that will not work for me because I need to capture the "aspxerrorpath" in the querystring for .net 404 errors. The IIS method will not give me that.
I am just hoping it is a server configuration I missed somewhere, but everything on production looks the same as on development.
I have a C# web forms ASP.NET 4.0 web application that uses Routing for URLs for some reason custom errors defined in the system.web section of my web.config is entirely ignored and it will fall back the IIS errors.
This gets entirely ignored
[code]....
This would be a minor inconvenience except that by the fact it falls back to IIS native instead of my application it completely circumvents Elmah logging my 404 exceptions correctly.
I want put custom error page in my website so I wrote below code in web.config
<httpErrors errorMode="Custom">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="error-404.aspx" responseMode="ExecuteURL" />
</httpErrors>
is it correct?
or I should put other code?
Here's my Application_OnError event sink in global.asax.vb:
Sub Application_OnError(ByVal sender As Object, ByVal e As EventArgs)
Dim innerMostException As Exception = getInnerMostException(Me.Context.Error)
If TypeOf innerMostException Is AccessDeniedException Then
Security.LogAccessDeniedOccurrence(DirectCast(innerMostException, AccessDeniedException))
Dim fourOhThree As Integer = DirectCast(HttpStatusCode.Forbidden, Integer)
Throw New HttpException(fourOhThree, innerMostException.Message, innerMostException)
End If
End Sub
You'll see that if we've got an innermost Exception of type AccessDeniedException we throw a new HTTPExcpetion with a status code of 403 AKA 'forbidden'
Here's the relevant web.config entry:
<customErrors defaultRedirect="~/Application/ServerError.aspx" mode="On">
<error statusCode="403" redirect="~/Secure/AccessDenied.aspx" />
</customErrors>
So what we're expecting is a redirect to the AccessDenied.aspx page. What we get is a redirect to the ServerError.aspx page.
We've also tried this:
Sub Application_OnError(ByVal sender As Object, ByVal e As EventArgs)
Dim innerMostException As Exception = getInnerMostException(Me.Context.Error)
If TypeOf innerMostException Is AccessDeniedException Then
Security.LogAccessDeniedOccurrence(DirectCast(innerMostException, AccessDeniedException))
Context.Response.StatusCode = DirectCast(HttpStatusCode.Forbidden, Integer)
End If
End Sub
Which unsuprisingly doesn't work either.
if I am redirecting to an error page from global.asax file, can I get hold of the page in which the error had originally occurred?
View 3 Replieshow to disable asp.net custom errors only for a specific ip address? this will ease debugging exceptions on my server from my office..
View 2 RepliesI am using asp.net 3.5 web.config to limit access and it works great.
<authentication mode="Windows">
<authorization>
<allow users="Bill, John"/>
<deny users="*"/>
</authorization>
Unauthorized (but authenticated) users will be blocked by a system error message saying that:
Server Error in '/' Application Access is denied.
Description: An error occurred while Error message 401.2: Unauthorized: Logon failed due to server configuration.
In order to make the message more friendly, I uncomment the customErrors flag and create a GenericErrorPage.htm in the root path of my project.
<customErrors mode="On" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
However, it just doesn't work. I still get the system error message rather than my custom error page.
To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
I got this error at time of running ma published website but only for 1page this error occurred how it can be solved.
I've searched a fair bit round and tried a number of potential solutions, suggested on their respective threads on various sites, to which none have worked for me.
My objective is to make sure the date entered, and to be stored, is not 'less than' (before) the present datei.e. Booking a reservation for a restaurant.
The first is:
"The ControlToValidate property of 'cvDate' cannot be blank..."
I've tried specifying it in page_load and .aspx source, the same has happened in both, in addition to ValueToCompare. I cant understand why it cant detect it?
C# (ControltoValidate):
Csharp Code:
[code]....
I am a more than a little confussled, my build succeeds with no errors but when I run without debugging only my error page shows up? I tried switching the custom errors to "Off" but it still shows up the error page.
View 5 RepliesI have a simple 'file download' generic handler which sets the response contenttype and headers before sending the file through the same response.
I also have Response.Cache.SetCacheability(HttpCacheability.server) set in the global.asax.
As I have noticed from various sources, Internet Explorer doesn't like this no-cache setting and gives an error when trying to download the file (requested site unavailable or cannot be found).
I thought maybe I could override this setting in the .ashx page, so I alter the response's cacheability setting to public. This did not solve the issue. removing the line from global.asax does solve the problem but obviously affects the whole site.
Is there a way of setting the cachability just for my generic handler?
If I were to specify a page for redirect using the ASP.NET Custom Errors feature, would my application still spit out the HTTP status code for that particular error?
For example if had a line in my web.config that had all Internal Server Errors redirect to Errors/500.aspx and then I encountered a 500 error, I would then be redirected to my custom Errors/500.aspx page. Will my application still respond with a HTTP 500 at any point in this exchange?
I have the following code but when i try and create a new IQuerable i get an error that the interface cannot be implemented, if i take away the new i get a not implemented exception, have had to jump back and work on some old ASP classic sites for past month and for the life of me i can not wake my brain up into C# mode. The code is to create a list of priceItems, but instead of a categoryID (int) i am going to be showing the name as string.
public ActionResult ViewPriceItems(int? page)
{
var crm = 0;
page = GetPage(page);
// try and create items2
IQueryable<ViewPriceItemsModel> items2 = new IQueryable<ViewPriceItemsModel>();
// the data to be paged,but unmodified
var olditems = PriceItem.All().OrderBy(x => x.PriceItemID);
foreach (var item in olditems)
{
// set category as the name not the ID for easier reading
items2.Concat(new [] {new ViewPriceItemsModel {ID = item.PriceItemID,
Name = item.PriceItem_Name,
Category = PriceCategory.SingleOrDefault(
x => x.PriceCategoryID == item.PriceItem_PriceCategory_ID).PriceCategory_Name,
Display = item.PriceItems_DisplayMethod}});
}
crm = olditems.Count() / MaxResultsPerPage;
ViewData["numtpages"] = crm;
ViewData["curtpage"] = page + 1;
// return a paged result set
return View(new PagedList<ViewPriceItemsModel>(items2, page ?? 0, MaxResultsPerPage));
}
I need to get the free Google charts working over SSL without any security errors. I am using c# and asp.net.As Google charts does not support SSL by default, I am looking for a robust method of using there charts but ensuring my user doesn't get any security warnings over their browser.ne thought was to use a handler to call the charts api and then generate the output my site needs.Similar to Pants are optional blog post. I haven't been able to get this example working at this stage.
View 3 RepliesI have custom errors set in the web config file as follows:
<customErrors mode="RemoteOnly" defaultRedirect="GenericError.aspx" />
Fine and dandy... I like that mode="RemoteOnly" facilitates development...
For unhandled exceptions, I have in global.asax:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Response.Redirect("GenericError.aspx")
End Sub
However, unhandled exceptions are going to the generic error page instead of the informative yellow screen of death preferred by developers. I can comment out the redirect in global.asax, but then I need to remember to change it for the production environment. Is there a way I can check in Application_Error whether I am remote or not to determine whether to redirect?
Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.
public
class
TngCheckBox :
CompositeControl
{
i have written the required properties which are working fine except the "checked" property. here is my code for 'checked' property. i tried both the below ways (commented one and not commneted) . the problem is the 'checked' value is not setting the value at the get set part of the property.its assigning the value at the design time , but when i check and uncheck its not updating the property value.which is resulting me wrong .
[Code]....
Iam developing a custom checkbox control deriving from the 'compositecontrol' which i need to use it for a composite control purpose.
public
class
TngCheckBox :
CompositeControl
{
i have written the required properties which are working fine except the "checked" property. here is my code for 'checked' property. i tried both the below ways (commented one and not commneted) . the problem is the 'checked' value is not setting the value at the get set part of the property.its assigning the value at the design time , but when i check and uncheck its not updating the property value.which is resulting me wrong .
[Code]....
When I implement Custom web control inheriting ASP.NET Menu Ajax is not working. I try to Override Render method and generate Li's rather than table.I try to use Control Adapters, but when I am not using adapters for some pages ithe base adapter is generating just hyperlinks with span. I do not want this way. So I can not use these.
View 1 RepliesI have a Web App (VS 2010 Beta 2, using VB) and it works flawlessly on the development system. When I publish it, everything works fine unless I use an update panel. If I use the update panel, and try to use something such as a dragpanel, I get the following error.
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; .NET4.0E)
Timestamp: Thu, 4 Mar 2010 14:54:25 UTC
Message: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 404
Line: 784
Char: 13
Code: 0
I have a log file with huge volume of errors logged. Now I want to · Screen the log file and find the recurrent errors that are logged. · Give the count of recurrent errors and their text.
View 2 RepliesDo anyone of you know how to handle XXX.X IIS HTTP errors in a web.config file? I tried doing the following:
<customErrors mode="On" defaultRedirect="error.aspx">
<error statusCode="403" redirect="error403.aspx" />
<!--NOTE: The following does not work-->
<error statusCode="403.9" redirect="error403.9.aspx" />
<!--ENDNOTE-->
<error statusCode="404" redirect="error404.aspx" />
</customErrors>
But obviously that didn't worked, because the web.config file expects an integer as the statusCode value.
CONTEXT: WinServer 2003 - ASP.NET 3.5
Using C# .NET 3.5 with VS 2008.
I've been playing with the FileUpload control for an upcoming project where the user is allowed to upload up to five files at once, but each file can only be 5MB in size. Simple enough all I would need to do is add in the httpRuntime element to the web.config and up the file size and timeout.
[Code]....
what I'm really getting at is there a better way to trap if the file size is too large before processing while using the FileUpload control. I would like to be able to keep the user on the same page but update a label control.
I am very new to ASP.Net and Visual Studio 2008. I am attempting to run a website on my Windows 7 Enterprise usig IIS7. When I load the web.config file in the VS2008 editor I get several errors/warrnings. Each starts with "Could not find schema information for the element 'TinyMCE' or it specifies one of the attributes.The section of code looks like this:
<TinyMCE installPath= "script/tiny_mce" mode ="src"
<globaoSettings>
<add Key ="relative_urls" value ="false" />
[code]...