When deploying to the IIS7, MVC3 reported a lack of resources to find the error, the file must be, and the page is sure to report the error, it is said that the internal operation errors, and MVC did not throw out the error;
So the right remedy, found that my project with Rexs for multi-language, and then found that the folder inside the App_GlobalResources is empty, according to the truth, should not be no file.
So I re-upload the App_GlobalResources folder, the problem solved.
The above is my problem solving, and I will introduce other similar problem handling methods as follows:
One, path configuration problems ( reproduced )
Sometimes "HTTP 404" appears when the program is running. The resource you are looking for (or one of its dependencies) may have been removed, or its name has changed, or is temporarily unavailable. Please check the following URL and make sure it is spelled correctly. "Error message.
Here we take the runtime to open the login page (login) as an example,
In general, there are two situations:
1. Error reason: The route is incorrect.
WORKAROUND: Open the project's "Global.asax" file, locate the route registration (RegisterRoutes ()) method, and change the controller in the route to "Login" on the line. The action method is typically selected as the default method () for "Index", but can be modified to suit your needs and is not shown here.
2. Cause of Error: Select an item in the view as the starting item.
Workaround:
(1), right-click the project Properties--Find web options. You will find that the value of the specific page option is the name of the view you set as the Start page.
(2), set the value of a specific page to "login" or "Login/index" (Index is the default, can be written without writing).
(3), run the project.
second, error capture problem ( reproduced )
In MVC, there is a filter that catches errors, but its usage is implemented using attribute, and can only be added to the Controller and action, so you can't catch the wrong one.
In fact, all the mistakes in theory must have been generated in the controller, but in 2 cases, they wouldn't have been captured.
1, the page does not exist when the corresponding controller is not found, then no controller is executed, so nature will not catch the wrong
2, in the Iauthorizationfilter error, error capture code in Iexceptionfilter, and Iauthorizationfilter priority is higher than iexceptionfilter, so also can not capture
protected voidApplication_Error (Objectsender, EventArgs e) {Exception Exception=Server.GetLastError (); Response.Clear (); HttpException HttpException= exception asHttpException; Routedata Routedata=NewRoutedata (); ROUTEDATA.VALUES.ADD ("Controller","Error"); if(HttpException = =NULL) {ROUTEDATA.VALUES.ADD ("Action","Index"); } Else //It's an Http Exception that let ' s handle it. { Switch(Httpexception.gethttpcode ()) { Case 404: //Page not found.ROUTEDATA.VALUES.ADD ("Action","HttpError404"); Break; Case -: //Server error.ROUTEDATA.VALUES.ADD ("Action","HttpError500"); Break; //Here's can handle views to other error codes. //I Choose a general error template default: RouteData.Values.Add ("Action"," General"); Break; } } //Pass exception details to the target error View.ROUTEDATA.VALUES.ADD ("Error", exception. Message); //Clear the error on server.Server.ClearError (); //Call target Controller and pass the Routedata.IController Errorcontroller =NewWEB. Controllers.errorcontroller (); Errorcontroller.execute (NewRequestContext (NewHttpcontextwrapper (Context), routedata)); }
View Code
Put this code in Global.asax, and create a new Controller called Error
namespaceMVC. controllers{ Public classErrorcontroller:controller { PublicActionResult Index (stringerror) {viewdata["Title"] ="WebSite website Internal Error"; viewdata["Description"] =error; returnView ("Index"); } PublicActionResult HttpError404 (stringerror) {viewdata["Title"] ="HTTP 404-File not found"; viewdata["Description"] =error; returnView ("Index"); } PublicActionResult HttpError500 (stringerror) {viewdata["Title"] ="HTTP 500-Internal server error"; viewdata["Description"] =error; returnView ("Index"); } PublicActionResult General (stringerror) {viewdata["Title"] ="HTTP Error occurred"; viewdata["Description"] =error; returnView ("Index"); } }}
View Code
so that you can catch all the errors. </p>
But in fact, this is not perfect, because if you refer to my first question, do not modify IIS settings under IIS6, run MVC, that when the suffix is not. aspx, the error will not be captured
Because the address entered at this time is not given to the Web site for processing, IIS throws an error directly because IIS believes that the suffix is not what you can do.
If the above content is helpful, order a praise Bai.
Record an MVC 3.0 error HTTP 404 The resource You are looking for (or one of its dependencies) may have been removed, or its name has changed, or is temporarily unavailable. Please check the following URL and make sure it is spelled correctly.