what kind of error this Server Error in '/' Application - c#

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.
Details: To enable the details of this specific error message to be viewable on remote machines, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "Off".
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's configuration tag to point to a custom error page URL.

That is the default generic error message in ASP.NET.
Re the more specific "what kind of error"; impossible for us to say; it could be a configuration error in web.config, it could be problems talking to the database, it could simply need a hug and some quiet time. Like the message says, either enable remote debug output, or look at the site from the server, and it'll tell you what is actually happening. Or look in the error log (event-viewer by default), which is perhaps more useful.
Note you can replace the error page with something more... user friendly if you like. Like the lolcatz on stackoverflow.com.

Edit the web.config file to have this
<system.web>
<customErrors mode="RemoteOnly"/>
</system.web>

Related

Getting Exception while retrieving Session.SessionID

I am getting an exception usually at night on a new project of mine. It is deployed to a hosting provider and visable to everyone.
My exception is:
Session state can only be used when enableSessionState is set to true, either in a configuration file or in the Page directive. Please also make sure that System.Web.SessionStateModule or a custom session state module is included in the <system.web><httpModules> section in the application configuration.
In my web.config there is:
<pages validateRequest="false" enableSessionState="true"
enableViewStateMac="true" enableEventValidation="true"
viewStateEncryptionMode="Always">
The exception is happening while getting Session.SessionID within one of my modules. This module is present on all pages in the application.
The application runs fine when I am here at work - but a night when I am not here this happens. I also never got this error while running application on my local dev machine. So I suspect a bot. Or possibly, hosting company shutting down services for some reason?
Is there any way to prevent this from happening? Like
if(Session.Isavailable)
or something I can add to my function in programmatically?

ASP.NET display "site down" page instead of YSOD if failure during startup

I'm trying to serve a custom "site down" page instead of the standard YSOD if the server were ever to fail during it's startup. Using <customErrors> inside of web.Config work's fine for any server error occurring after startup has completed successfully, but in this case the YSOD response is not replaced.
Other resources have lead me to adding app_offline.htm to the root of the project and playing with its name during deployment, but this does not tackle unexpected server issues occurring during startup.
Is there a way to serve a "default" page if there are any errors or a proper HTTP response could not be formed?
Yes there is a way to do that but that depends how you want to handle those errors.
If you want to redirect to the same error page on any 4xx or 5xx status codes then you can use the below code in your web.config file
<customErrors mode="On" defaultRedirect="Error.aspx">
</customErrors>
In error page you can display some user friendly message.

Why does the 404 page not work in certain cases? (IIS, Classic ASP)

Explanation
In production and locally, the 404 page for my site works fine for the most part. A URL such as http://localhost:43424/gibberish_r3hjjnwef will return the well designed 404 HTML page that is in the website folder, and pointed to by IIS.
However when I change the this URL to http://localhost:43424/gibberish_r3hjjnwef... it gives the following "hard" error, whilst still claiming to be a 404.
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /gibberish_r3hjjnwef...
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2110.0
I'd rather it still gave the 404 HTML page.
I thought maybe it was an outright invalid URL, but both http://www.bbc.co.uk/news/fdisdhfdu and http://www.bbc.co.uk/news/fdisdhfdu... give the BBC's nice 404 page.
Question
Is there anything I can do to improve this?
Relevant Information (happy to provide more if necessary)
Microsoft .NET Framework Version: 4.0.30319
ASP.NET Version: 4.7.2110.0
Language/Framework:C#/Classic .ASP
I'm not sure whether this is what you are referring to, but maybe try this out:
Go to IIS Manager -> Site -> IIS Error pages. On the right hand panel, there's a setting "Edit Feature Settings...".
The options there mean:
Custom error pages: Use the 'IIS error pages' as fallback for all failed requests (e.g. your 404 page set up the list behind)
Detailed error pages: In case of an Asp.Net error, shows the 'Asp.Net error page' ("Server Error in '/' Application." etc.)
Detailed errors for local requests etc.: Show the 'IIS error page' for remote requests, for local requests show the 'Asp.net error page' ("Server error in '/' etc.)
This is in place to effectively hide the detailed Asp.net error page (with the stack trace etc.) from external callers as you may not want to give them the details of your application. This is the default setting, where you should only see the 'Asp.net error page' when you call the invalid URL on 'localhost', but the 'IIS error page' (404) when you call the page from a different computer.
So, what you may want to try is to select the "Custom error pages" option ('IIS error pages' for all failed requests).

Adding Virtual directory under DNN website ,

I want to create virtual directory in my DNN website and make new database for this site , for this I go to IIs manager and click add virtual directory and browse that site it shows error
HTTP Error 500.19 - Internal Server Error The requested page cannot be
accessed because the related configuration data for the page is
invalid.
Module IIS Web Core Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'add' with
unique key attribute 'name' set to 'LogoffHandler*'
Config File \?\C:\Website\dnndev.me\web.config
Requested URL http://www.dnndev.me:80/VirtualDnn Physical
Path C:\Website\dnndev.me Logon Method Not yet determined
Logon User Not yet determined Config Source 116:
117:
118:
Please tell me how can i resolve this problem ........
Thanks
You might need to add
<location inheritInChildApplications="false">
To your web.config file so that DotNetNuke stops handling requests to that virtual directory.
Something along the lines of what is mentioned in this answer https://stackoverflow.com/a/782277/21362
An old blog post I wrote might also help
http://www.dotnetnuke.com/Resources/Blogs/cid/135153/DotNetNuke-Tip-15-Running-a-webservice-inside-of-a-DNN-site.aspx

How I can fix MAC error in asp.net application?

I have an ASP.NET application all things are working fine but after some minutes when I click on a button it gives me this error :
Validation of viewstate MAC failed. If this application is hosted by a Web
Farm or cluster, ensure that
configuration specifies
the same validationKey and validation
algorithm. AutoGenerate cannot be used
in a cluster. Description: An
unhandled exception occurred during
the execution of the current web
request. Please review the stack trace
for more information about the error
and where it originated in the code.
Exception Details:
System.Web.HttpException: Validation
of viewstate MAC failed. If this
application is hosted by a Web Farm or
cluster, ensure that
configuration specifies the same
validationKey and validation
algorithm. AutoGenerate cannot be used
in a cluster.
How I can resolve this ?
This blog post covers this in quite a bit of detail:
http://www.eukhost.com/forums/f15/fix-validation-viewstate-mac-failed-6085/
In the past i've used this method:
<system.web>
<pages enableViewStateMac="false" />
</system.web>
setting enableviewstatemac to false means if the encoded view state changes your view state won't be replaced with the older one, this can be a security issues. instead of this, after seeing your error put a persistence machine key in web.config if you are in web farm scenario because dynamically generated machine key tends to view_state error.

Categories