I don't know about ASP.Net at all, I right click on the file Index.cshtml in views and accidentally choose "Set As Start Page"
Now when I run the application (Ctrl+F5), the error occurs
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: /Views/Home/Index.cshtml
You can change the settings in the Project properties, this other stack article should help: Visual Studio ASP.Net MVC undo set as start page action
Related
I'm going through the exercise from the book (just starting to learn MVC). I have made the following change to RouteConfig.cs file:
routes.MapRoute("Contact", "Contact/{*pathinfo}", new {
controller = "Home", action = "Contact" });
routes.MapRoute("About", "About/{*pathinfo}", new { controller =
"About", action = "About" });
The contact page works absolutely fine but the About just throws error when trying to access it via http://localhost:49899/About
Error: 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: /About
I cannot see any difference between those 2 lines of the code, can anybody point me to what I'm missing? This is a brand new project with all the default settings and scaffolding.
When you created the default project, all kinds of wizardry happened behind the scenes for you. The default project most likely came with an auto-generated HomeController, an auto-generated Home folder to contain Views that the Home Controller will call, some Actions that correspond to those Views.
You probably do not have a Controller named About. The route that you have defined for About is saying that to get to the About page you would go through the About controller and call the About Action. Most likely you need to hit the Home Controller and then the About Action.
P.S. MVC uses naming conventions to infer where things are. You'll probably find an About view in the view folder named Home. Are you seeing a pattern here?
Routing docs
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).
I have a web site and when I try to view/access through IIS(Default Web Site -> Search/Run Site -> Search *:80(http)) the site open.
But when I try to open/debug using Visual Studio 2010, the following problem happens:
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: /help
If I am in home page(root "/") and I try to open any page, open the "Directory Listing"
What is happening ?
It sounds like the problem is in your routing (Route.Config). Make sure you change your routing to follow how your website is set up in IIS.
Currently I am Working with MVC4.I have doubt, I tried to debug when index.cshtml is open ,
It shows 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: /Views/Report/Index.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929.
When I debug with other pages than index.cshtml, it works fine.Why it happens? Can you please give resolution?
I think you are requesting wrong URL: /Views/Report/Index.cshtml
It should be hostname/Report/Index i.e. http://localhost/Report/Index
You are calling it wrong way..
Your request pattern should be as follows:
ControllerName/ActionName
Therefore your request sholud be http://localhost/Report/Index
The process is as follows:
When you will hit http://localhost/Report/Index
your request will get redirected to Index Action located in ReportController.cs
Then the Index Action will return the Index.cshtml view located in "Views/Report" folder.
I am getting an error on my browser when i try to edit or delete it says:
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: /console/Delete/PS3
But the strange thing is when i put my mouse cursor into the browser address bar and press enter the delete and edit page appears
Can you please help me with this. If you need any information regarding this just let me know and i will provide.
Check if you have added routing for "/".
In most cases it is because of omitted routes.
I guess it is because the related actions has [Get] attribute defined on them, so add [Post] attribute should solve the problem.