Using customErrors returns Server Error in '/' Application

K

kristian

I'm using the following entry in my web.config:
web.config
<customErrors mode="On" defaultRedirect="~/CMS/Default.aspx">
<error statusCode="404" redirect="~/CMS/Default.aspx"/>
</customErrors>

And this is in the Global.asax
Global.asax
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
HttpContext ctx = HttpContext.Current;
string path = ctx.Request.Path.ToString();
ctx.Response.Write(path);
ctx.Server.ClearError();
}

When I test this on my laptop using Visual web express I can see the
Request.Path written in the browser, but when I upload it to my
webserver I get the error:

Server Error in '/' Application.
Runtime Error
Description: An application error occurred on the server. The current
custom error settings for this application prevent the details of the
application error from being viewed remotely (for security reasons). It
could, however, be viewed by browsers running on the local server
machine.

I want to use the customErrors and the code inside the global.asax but
how? Why is my webserver returning this message and my local test
isn't?

I dont host my own webserver, the website is hosted by a company and I
have no access to the servers controlpanel.

How can I get this to work?
 
A

Aytaç ÖZAY

Hi,

If your host server uses port directing for hosting the web site, you can
get "Server Error in '/' Application". Try to use the full address insread
of "~/CMS/Default.aspx" this address.

Have a nice work,

Aytaç ÖZAY
Software Engineer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top