There are strange things about developing. NET MVC3 today.
With Firefox, open the index page, request the index controller many times, query the database code to execute multiple times, the server slows down,
And did not refresh the page, over a period of time there are one or two requests, infinite cycle, this thing has never met, really confused.
Seriously check the reason, the original is the image of the SRC, the database path is not in the case, src= "/", directly requested the default index controller.
Then, by adding a piece of processing code to the index controller, you can also display a default picture without a picture.
The code is as follows, added to the front of the controller.
if (request.urlreferrer! = null)//The Urlreferrer of a page request is the page itself
{
string accept = request.headers["accept"];
if (Accept.startswith ("image/"))//Picture request is generally: image/png,image/*;q=0.8,*/*;q=0.5
{
Return File ("/content/images/show/show_pic07.jpg", "image/jpeg");
If it is a picture src request, return a default picture, after which the code querying the database does not repeat.
If you do not return the correct picture, Firefox will loop the request indefinitely.
}
}
Summary: Originally 10 minutes can solve the thing, spent half an hour, this and experience, development process, have to accumulate experience.