Server Error in '/' Application - Runtime Error - Asp.net [closed]

3

My application has custom errors working correctly.

Only when "/ ....." is added at the end of the URL (necessarily with more than two points), the unrecovered error "Server Error in '/' Application" appears.

If I add only two points, the application "goes up" one level, as if changing the directory.

I need this to be transparent to the user.

Has anyone ever gone through this? Any light?

    
asked by anonymous 30.11.2016 / 22:08

2 answers

2

Even with the treatments described by @Taisbevalle, the site could not redirect to a default error page when you added any number of points to the end of the URL.

The solution was to add the tag, in Web.Config:

     <system.web>
       <httpRuntime relaxedUrlToFileSystemMapping="true"/>
        ....
     </system.web>

The path created by / .... was not configured as a valid path. When we set true to the relaxedUrlToFileSystemMapping parameter, we allow filenames to not obey the Windows file standards, thus being able to throw "404" exceptions and be treated by the treatment explained in @Taisbevalle's response .

Documentation

    
01.12.2016 / 15:58
2

This error is appearing because you are encountering a problem with your application. You can change this in Web.Config . It has a tag that calls customErrors , put it as Off .

<configuration>
  <system.web>
    <customErrors mode="Off"/>
  </system.web>
</configuration>

Remembering that you have to deal with errors. My suggestion is you create an error page that redirects the user whenever an unexpected error occurs. For this, you use the customErrors tag and set a page in defaultRedirect . You can handle every mistake with a page. For example a common error is the "HTTP 404 Page Not Found", you can use the statusCode of tag error . Another useful parameter is mode that defines which errors are going to be displayed to the user. There are 3 values:

  • On : Any error will be redirected to the defined page.
  • RemoteOnly : When you are running the local application, the error will be displayed. When running remotely, it will be redirected.
  • Off : The error will always be displayed.

Some statusCode :

  • 404: Page not found (File not found)
  • 403: Access denied
  • 500: Server Error

An example of Web.Config :

<configuration>
  <system.web>
    <customErrors mode="On" defaultRedirect="pagErro.aspx">
      <error statusCode="404" redirect="pagNaoEncontrada.aspx" />
    </customErrors>
  </system.web>
</configuration>

Documentation

    
01.12.2016 / 13:24