ASP. NET mvc3 on Mono (1): deployment in Windows

Source: Internet
Author: User
ArticleDirectory
    • Environment preparation
    • 1. An error occurred while using the xsp server of Mono 2.10.
    • 2. Use nginx + FastCGI-mono-server on Windows to set up the mvc3 site. However, after the form is submitted, modelbinder cannot properly bind the action model.

The message that mono 2.10 supports mvc3 and razor really makes me very excited for a while, because after mvc3 is supported, I may perform tests related to compatibility of kooboo cms3 with mono. After a while, I found that there is still a little distance from my goal. I don't know whether it is a bug in Mono 2.10 or why. I am always unable to run mvc3 sites perfectly in mono, the same applies to simple sites created using the default mvc3 site template. I have been living in Microsoft Windows for a long time /. in the moisturizing environment of the. NET platform, I have no experience in using the Linux platform and the Web deployment habits based on configuration files. It took me a lot of time to solve the originally simple problem. From xsp failure, to the use of nginx + FastCGI in Windows to host ASP. NET mvc3 site, it took another half a weekend to study mono deployment in opensuse. Although it does not solve the mvc3 running problem, we have finally figured out how to deploy ASP. net sites in Mono and simple Linux platform (opensuse) operations. Below is a simple record of these difficult processes:

Environment preparation

In vs2010, use the default mvc3 site template to create a simple MVC site with a simple homepage and logon page, and deploy mvc3 Dependencies under the bin.ProgramBesides Microsoft. Web. Infrastructure. dll. Download the website.

1. An error occurred while using the xsp server of Mono 2.10.

Mono supports cross-platform services, including windows. It also provides a very simple way for us to easily start a web site through mono, Which is xsp. After Mono is installed successfully, it adds the menu item "xsp 2 web server here 2.10" to the right-click menu of the directory ", however, we only need to simply select this menu item to run the directory as a web site using mono. Here, xsp2 indicates that ASP is used. NET 2.0, if you need to use ASP. net 4.0, you can add a similar menu item by modifying the registry, just change the execution batch from xsp2.bat to xsp4.bat. This was originally the simplest test solution, and I used mono2.8 to start the MVC2 site. As a result, in Mono 2.10, The xsp site does not respond. The request allows him to run for 10 thousand years, and it is also loading or timeout. The problem cannot be solved through various efforts.

2. Use nginx + FastCGI-mono-server on Windows to set up the mvc3 site. However, after the form is submitted, modelbinder cannot properly bind the action model.

Xsp does not work. You can only find other methods. After trying to use Apache in windows, I chose nginx + FastCGI to construct the ASP. NET site. In the garden, find this introduction and set up ASP in mono.. Net site. However, according to this article, I have never figured out how to configure it. It seems very complicated. I still need to download the files it provides, but it is fruitless. Fortunately, I found the nginx mono configuration file on Mono's official site, but it is a configuration under Linux. It doesn't matter. The configuration is just a few steps. It should be very simple. Some problems were also encountered during the period, but they were all solved smoothly. The following is a simple record of the steps for nginx + mono to deploy ASP. NET sites in Windows:

1) download the latest nginx software from the official nginx website. It is pure green and does not require installation. After the download, decompress it to a directory where E: \ mono \ nginx-0.9.4

2) For convenience, copy your asp. Net Site to the nginx directory. The directory name I use here is mono_mvc3.

3) Go To The conf directory, find nginx. conf, find location/{}, and change this configuration to our own value:

 
Location/{root mono_mvc3; # Use E:/a/B/c fastcgi_pass 127.0.0.1: 9000 for other absolute paths; fastcgi_param script_filename $ document_root/$ fastcgi_script_name; Include fastcgi_params ;}

There should have been a row of fastcgi_index default. aspx, which is used to set the default page. However, this line of configuration is removed because I am a host MVC site. If this line is not removed, the root directory of the site will be inaccessible.

4) Deploy the MVC site. In addition to removing the default homepage settings, you also need to find the fastcgi_params file in the conf directory and add the following two lines at the end of the file:

 
Fastcgi_param path_info ""; fastcgi_param script_filename $ document_root $ fastcgi_script_name;

5) The configuration is complete. Here we can use the mono FastCGI server. If this command line is slightly incorrect, it will make our site unavailable. Combined with the information of various parties, the command line that I can work normally is:

D: \ Program Files \ mono-2.10 \ bin> fastcgi-mono-server4/socket = TCP: 127.0.0.1: 9000/root = "E: \ mono \ nginx-0.9.4 \ mono_mvc3"/applications = /:. /multiplex = true/Port = 8080

6) in the last step, run: nginx.exe. Note: you only need to double-click to run it. Double-click will be executed in the background, without running it under the command line.

The above is the most detailed configuration steps for nginx + mono in windows. Under normal circumstances, we only need to access http: // localhost: 8080 at this time, the site should work properly. However, due to mono 2.10 and mvc3, I still encountered the following problems:

1) every time FastCGI-mono-server parses the site for the first time, an error will occur. You can access the site after refreshing the page.

2) When we redirect to the logon page, enter the user name and password, and submit it again, another problem occurs, and the action cannot be executed:

In fact, in my initial attempt (another machine), no exception is thrown. The submission process is normal, but you are prompted not to enter the user name/password, that is, the logonmodel attribute is not properly bound through modelbinder. I don't know whether different compilation versions are provided in the official download.

The deployment in Windows is successful, but there is still a problem of incorrect running. So I took a look at Linux to see if the deployment under Linux is correct. After all, the main deployment scenarios of mono are still in non-Windows platforms.

Follow-up: ASP. NET mvc3 on Mono (2): deployment in Linux (opensuse)

Related Article

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.