ASP.NET errors display my local development folder? - c#

I have a inherited asp.net project. I never had this issue in others projects,so this is completly new for me.
In my web.config, I put that the errors in customErrors mode="Off", and any error in the app is displayed on the screen.
The problem, is that the errors, displayed my develop local directory folder, when the site is published on other server...
Exameple:
ASP.NET Error
The connection of the server it's Close.
Error in C:\Develop\myProject\file.cs\MethodName() <- ?¿
Someone know what's happening?
Thanks

The stack trace information shown when there is an error is fetched from the symbol information being produced during compilation. It is stored in the pdb-files. The symbol information refers to the location of the files during compilation. When deployed, the source .cs files are not even present on the target system, it just shows what's in the pdb.
This is completely normal behaviour and nothing to worry about.
As others have noted you should never leave customerrors off on a production server as the stack trace might reveal sensitive information.

By setting the customErrors mode="Off" will expose all exceptions thrown and exposes the errors thrown YSOD (Yellow Screen of Death)
If you want to hide these then set the option to "On" and then this will only show your custom error message/page. If you still need to see these error's then set it to RemoteOnly and this will show the YSOD on the local machine the site is deployed too but show the Custom Errors to everyone else.
As for showing your development folders this is because it is just using the information where the dll's were compiled.

Related

Saving text to image in server

I am following the link to save text to image from the following link:
How to generate an image from text on fly at runtime . Taken the code from the accepted answer .
It is working fine in local machine.
The same program is promoted to a build server in a remote machine. And the url I am accessing from my local machine to save the text to image.
The output says "Image is saved", but actually the image is not saved in the path saved in web.config of remote server.
I am not even getting any error message to know whats the problem as there is no exception.
I am running out of ideas as in what could be the issue and why the image is not getting saved. Any suggestions?
Here are some things you can do:
Make sure the folder where you are writing to foresees modify rights to the IIS Apppool identity of the application. You'll need to add it by searching for it in full instead of just the identity, so
IIS APPPOOL\YourAppsIdentity
(note the space between IIS and APPPOOL) and be sure to set the search location to the server machine, not to the domain, which is what it would default to if the machine is joined into one (otherwise the name won't resolve).
In your application's Web.config file you could also set <customErrors mode="Off"> (in the <system.web> section) during development so you get some more verbose error descriptions in the browser window if or when exceptions do bubble up. They can help you on your way to figure out what's going wrong. Don't forget to remove the entry from the Web.config file again once the application goes into production or set the value to "On" if you do, in fact, use custom errors.
You can make this code a little more robust by doing some access control checks on the directory before attempting a write operation. this can help you on your way.
Hope this helps.

ASP.NET page cannot be displayed error while running in the debug mode

My application was running fine in the debug mode, however, out of the blue (without changing any web.config or global.asax.cs file) One of the pages stopped loading, and it started giving me a "page cannot be displayed" error.
I have tried everything suggested in the following links:
How to fix "This page can't be displayed" error in ASP.NET?
http://forums.asp.net/t/1934509.aspx?How+do+I+fix+This+page+can+t+be+displayed+error+in+asp+net+c+
What's baffling is that it is not even connected to any internet, I am trying to debug my application on local host... Is there something I have missed or need to check for this particular error to go away. I have no content in global.asax.cs and my customerrors mode is 'off'. What else can lead to this error.
I figured the answer to this one, basically, the page that was not loading had an upload option, which(uploadbtn_click) thereafter was redirecting to the "page cannot be displayed" error page.
The reason was that when we run the code in debug mode, Visual Studio launches its own version of IIS and self-hosts the site to run temporarily. However, it doesn't allow a lot of memory for upload/download. Which is why this error.
Hence, this problem would go away if we host the file in IIS, because there we get a default of 50 MB for such actions.
To solve the problem - in web.config file in section add next parameter :
2097152 = 2G

Exception for path of "/null" being thrown on all controller index methods

As of today all branches of our codebase (old and new), our staging environment and our live environment are all throwing the following exception when the Index method of any Controller is viewed in a browser:
System.Web.HttpException: The controller for path '/null' was not found or does not implement IController.
To clarify, this is even happening on code that has long since been checked in and has not been edited, when I open the project and browse to the homepage of the application. Other members of the team are also experiencing this on their own branches as of this morning too.
The exception is thrown but the respective Index page is rendered as you'd expect so the exception being thrown is silent to the user.
It looks to have started happening on our production site at just after midnight. No publish was undertaken and no Windows Updates were installed on the server. I did install yesterday's wave of Windows Updates on my own PC. I'm baffled! Any ideas?

Access to the path 'xxx' is denied (where 'xxx' is a folder)

I know this has been asked before many times, but I have browsed tens of similar questions without help.
This error is showed when my asp.net 4.0 application tries to access a folder on my local drive, doing this:
XmlTextReader confReader = new XmlTextReader (filename);
while (confReader.Read()) // <- error line
{
// do something
}
In my web.config I have <Identity Impersonate="true">. For the folder I have assigned full-access to:
everyone
IIS APPPOOL\<custom apppoolname>
NETWORK SERVICE
Debugging the application, I can put up a watch which evaluates this call right before the incriminated line:
System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
the call shows the current user is IIS APPPOOL\<custom apppoolname>.
I'm on Windows 7 64bit with Sp1. I know it's probably something stupid but I have already spent an awful amount of time on this.
Edit:
The problem was in the variable "filename", which pointed to the right folder, but for a configuration problem the filename was missing (i.e. the content was "c:\data\" instead of "c:\data\file.xml"). The Asp.net error was actually confusing, since I had all the right permissions to access that folder. DJKRAZE pointed me to the right direction.
Here is what I would suggest checking
where are you declaring filename..?
Does the file even exist..?
do you have rights to that folder..? have you tried running VS as Admin..? do you have Virtual Directory setup for the web app..sounds like you have a few things configured improperly as well but can't really tell based on the code for starters this line System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();
should yield your domain\\username or compuername\\username
Glad that FileName was all it was
IIS requires the path to a folder in the server machine has rights for Anonymous user login to access.
Make sure the user Anonymous has the rights to access the folder.

Nerd Dinner returns 404s for all sub-pages

I just got a new Windows Server 2003 machine and I've been trying to get Nerd Dinner onto it. The server already has .NET 3.5 SP1, ASP .NET MVC, etc.
When I upload Nerd Dinner via FTP to a subdirectory of the main webpage, I get a 404 when I go to any page in the site except for the root and the home page doesn't event show the map.
For example, when I go to the about page, I get the following IIS log entry:
2009-08-13 17:56:10 128.200.123.118 GET /nerddinner/Home/About - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip>) 404 0 3
I'm extremely puzzled because this is a freshly downloaded and compiled copy of Nerd Dinner from Codeplex.
In case it helps, here's a log entry from the failed attempts to get the JavaScript for the map (note the complete lack of "/nerddinner"):
2009-08-13 18:03:05 128.200.123.118 GET /Scripts/Map.js - 80 - 128.200.123.89 Mozilla/4.0+(compatible;+MSIE+8.0<snip>) 404 0 3
I have a strong feeling that I should be able to fix this inside the asax.cs file but I can't quite get it to work even after appending "nerddinner/" to the front.
Any ideas for what's happening?
Edit: I uploaded it to the root of the webfolder and the 404s continue.
Edit 2: Thanks for the suggestions. I followed the instructions and now I don't get 404s. However, there are 2 major problems left:
The scripts and content folders don't map correctly. I get 404s on all references to the files inside those folders.
I can't view dinners at all. I get:
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
and a line in red that says "<connectionStrings configSource="ConnectionStrings.config" />". Except that ConnectionStrings.config doesn't exist on the server, so it wasn't an important file according to VS, and thus, I have no idea what the error is referring to.
(a quick search of my local hard drive turns up a ConnectionStrings.config file with nothing in it)
Edit 3:
Now I think I'm getting the equivalent of a SQL Server 404 when I go to view dinners...
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
Summary To Help Others Running ASP .NET MVC on IIS6, Especially Nerd Dinner:
IIS 6 may throw piles of 404s at you because it doesn't understand that files can have no extensions. To solve that, follow the steps in Phil Haack's blog post.
ASP .NET MVC URL rewriting is not magic. It only rewrites URLs that are piped through code. References to scripts, images, databases, direct links (aka a href tags; not the ones that are dynamically generated) etc. are not remapped based on the directory of your application. For the Nerd Dinner application, go through the pages and add "/nerddinner/" in front of references to these references. Substitute "nerddinner" with the name of your subdirectory.
Take the database and attach it to SQL Server (or SQL Server Express) on your server. Add the Network User to the database with read/write roles.
Fill in the correct connection string for your setup. In my case, I was referring to the server by IP address and using SQL Server 2005 so my connection string is:
<add name="NerdDinnerConnectionString" connectionString="Data Source=128.200.123.118; Initial Catalog=NerdDinner; Integrated Security=SSPI" providerName="System.Data.SqlClient.SqlConnection"/>
Are you running it on IIS6? If you are, you will need to patch the route table to take into account the .ASPX extension, which IIS6 more or less requires.
Phil Haack has a good walkthrough that explains this process. He also explains ways you can do it without the .ASPX extension:
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
The scripts and content folders don't
map correctly. I get 404s on all
references to the files inside those
folders.
In ASP.NET MVC files do not map one for one to an URL, like they do in ASP.NET. Instead, a match in the routing table diverts a GET or POST request from the browser to a controller method in one of your controllers. From there, the controller decides (either explicitly or by convention) which View to display.
An error occurred during the
processing of a configuration file
required to service this request.
Please review the specific error
details below and modify your
configuration file appropriately.
ConnectionStrings.config needs to exist on the server, since it is being referenced in web.config. It's an include file, so there doesn't necessarily have to be anything in it. But if it is being referenced, it needs to be included on the server, so just copy it there with your FTP program.

Categories