developing. Net MVC3 encounters strange things + solutions

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.