ASP. net mvc and IIS Problems

Source: Internet
Author: User

H. I have been using Asp.net MVC over the past two days. I think it's okay. It's very similar to monorail. I think it's faster to get started. The function is derived from MS, so the continuity is better, many existing resources can be used up. However, the installation in this book is a bit problematic, mainly because of the compatibility between IIS and MVC framework.

========================================================== ==========================================

ASP. net mvc Framework relies on ASP. net routing to forward browser requests to Controller behavior. To use ASP. NET routing, you must perform some additional configuration steps on the Web server. Different IIS versions and the request processing module of your program determine the configuration steps.

Here is an overview of IIS configurations for different versions:

  • Iis7.0 (integration mode)-No special configuration for ASP. NET routing is required
  • IIS 7.0 (Classic mode)-Special configuration for ASP. NET Routing
  • IIS 6.0 and earlier-some special configurations need to be made for ASP. NET Routing

The latest version of IIS is 7.0. Windows Server 2008. Of course, you can also install IIS 7.0 on all Vista versions except home basic.

IIS 7.0 supports two request processing modes: integration mode and classic mode. In integration mode, you can use ASP. NET routing without any configuration. In Classic mode, some additional configurations are required.

Microsoft's Windows Server 2003 contains IIS 6.0. In the 2003 system, you can upgrade IIS 6.0 to 6.0. in IIS, additional configurations are also required.

IIS 5.1 is installed in Microsoft Windows XP Professional and must also be configured in 5.1.

Finally, IIS 2000 is installed in Microsoft Windows 2000 and Microsoft Windows 5.0 professional. You also need to configure IIS 5.0.

Integrated Classic Mode

IIS 7.0 can process requests in two different request processing modes: integration mode and classic mode. The integration mode provides better performance and more functions. Classic mode is used to maintain backward compatibility with earlier versions of IIS.

The request processing mode is determined by the program pool. By setting the program pool, you can set the processing mode used by the web program. Follow these steps:

1. Open the IIS Program

2. In the connections window, select a program

3. In the actions window, click Basic settings to open the program editing dialog box (figure 1)

4. Pay attention to the selection of the program pool

By default, IIS has two program pools: defaultapppool and clasic. Net apppool. If defaappapppool is selected, your program runs in integration mode. If classic. Net apppool is selected, it runs in Classic mode.

Figure 1: view request processing mode

Note: In this dialog box, you can modify the request processing mode. Click "select" and modify the program pool of the program. Note that changing ASP. net programs from the classic mode to the integration mode requires some compatibility. More information can be found in the following articles:

  • Upgrading ASP. NET 1.1 to IIS 7.0 on Windows Vista and Windows Server 2008 -- http://learn.iis.net/page.aspx/270/upgrading-aspnet-11-to-iis7-on-windows-vista--windows-server-2008/
  • ASP. NET integration with IIS 7.0-http://learn.iis.net/page.aspx/243/aspnet-integration-with-iis7/

If an ASP. NET program uses defaultapppool, ASP. NET routing can run normally without any configuration. If the Classic. Net apppool is used, you need to modify it.

Use ASP. net mvc in earlier versions of IIS

If you need to use ASP. net mvc in versions earlier than IIS 7.0, or want to use the Classic Mode in version 7.0, you have two methods to implement it.

1. Modify the route table to use the file extension. For example, use store. aspx/details to replace the stroe/details URL request.

2. Create a project named wildcard script. Map (wildcard script redirects to ing. You can transfer all requests to ASP. NET Framework.

If you do not have the permission to access your web server (for example, your ASP. net mvc program runs on the server operated by the Internet service provider), you need to use the first method. If you do not want to change the rendering method of your url, you must use the second method on the server side.

Next we will study these two methods in detail.

Add an extension to a route table

Modify the route table in the global. aspx file. The default unmodified global. aspx file in listing1 configures a "default" route.

Listing 1-Global. asax (unmodified)

Code
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. MVC;
Using system. Web. Routing;

Namespace mvcapplication1
{
Public class globalapplication: system. Web. httpapplication
{
Public static void registerroutes (routecollection routes)
{
Routes. ignoreroute ("{resource}. axd/{* pathinfo }");

Routes. maproute (
"Default", // route name
"{Controller}/{action}/{ID}", // URL with Parameters
New {controller = "home", Action = "Index", id = ""} // parameter defaults
);

}

Protected void application_start ()
{
Registerroutes (routetable. routes );
}
}
}

Through the routing configuration in Listing 1, you can switch to the following URL:

/Home/Index

/Product/details/3

/Product

Unfortunately, requests in earlier versions of IIS will not be transferred to ASP. NET Framework. Therefore, these requests are not forwarded to the Controller. For example, if you enter/home/index for low vision, the error prompt page shown in Figure 2 is displayed.

========================================================== ====================================

Iis5 has only one website.

1.
Ensure that. NET Framework 3.5 SP1, Asp.net MVC 1.0, or 2.0 is installed in the XP environment.
2.
Since iis5.1 only has one default website, first place other files on the default website to another location and copy the project files to the directory where the default website is located (generally: C: \ Inetpub \ wwwroot ), modify the connection string.
3.
After completing the preceding steps, you must configure iis5.1. First, right-click the default website and choose "properties"-"main directory"-"configuration"-" ing"-"add" and select aspnet_isapi.dll (general path: C: \ WINDOWS \ Microsoft. net \ framework \ v2.0.50727), and then enter ". * "Be sure not to check" check whether the file exists "and click" OK.
Okay, the program can be accessed normally.

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.