Asp. Net Mvc3 deployment in Mono

Source: Internet
Author: User
Tags stack trace

 

When trying to deploy the MVC3 project on mono (2.10), we found two problems: one is that the entities from ModelBinder in all MVC3 actions are null, and the other is Lucene. net encountered the "UNC paths shocould be of the form \ server \ share" error.

 

For question 1, after experiment, it is found that mono cannot get the value through Request as long as it is a post Request, because Request. form. keys. the Count value is always 0. The same problem exists even if apache runs xsp4 directly. The MVC version of HttpContext is obtained in the related class library of MVC3, while System. web. mvc is deployed in private mode, so the problem either occurs in mono's System. the implementation of the Web either occurs in XSP and has gone through a painful search. It is mentioned that defamodelmodelbinder cannot be used in mono. It is also mentioned that mono is not enough to fully support MVC3 at present, however, if no POST request data is initialized at the root of HttpContext, no ModelBinder can spell out a Model. Later, I found some clues in the BUG correction list of mono. On the Release notes page of mono 2.10.2, BUG683339 mentioned:

683339: POST variables are not transferred to HttpContext. Request. Params nor FormCollection in MVC3 app

No wonder. In versions earlier than mono2.10.2, POST data cannot be read in MVC3. After mono2.10.2 is updated, ModelBinder works properly.

 

For question 2, it is the IO exception caused by the difference between the "\" and "/" Paths in windows and linux. In fact, when migrating from windows to linux + mono, 80% of the problems are caused by URL case sensitivity and windows/linux path. This exception is traced upwards and the following message is displayed in Stack Trace: www.2cto.com.

At PanGu. Dict. WordDictionary. LoadFromBinFile (string, string &) <IL 0x00014, 0x00089>

It is assumed that pangu word segmentation uses a hard-coded path Separator in the path when reading the dictionary. This method is located through Reflector and the code is displayed as follows:

Public string GetDictionaryPath ()

{

String dictionaryPath = this. DictionaryPath;

String currentDirectory = Directory. GetCurrentDirectory ();

Directory. SetCurrentDirectory (Path. GetAssemblyPath ());

DictionaryPath = Path. GetFullPath (dictionaryPath );

Directory. SetCurrentDirectory (currentDirectory );

Return Path. AppendDivision (dictionaryPath, '\'); // <---------- hard-coded Path separator is used here

}

The source code of Pangu word segmentation is downloaded, And the dictionary path is changed to read from the configuration file. After Pangu. dll is re-edited and deployed, it can be searched normally. This also teaches us to develop good habits, use hard coding as little as possible, and consider the applicability of code in multiple environments.

The above is a bit of Debug experience using mono. Many people may encounter the same problem and hope to help.

By the way, after several rounds of stress tests, we found that mono's performance is not bad at all. If you have doubts, believe in science, believe in experiments, and try it on your own.

 

From the wind voice

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.