Configure ASP. NET MVC under Mono

Source: Internet
Author: User

Cause

Life is endless, tossing and turning. New MacBook, with the principle of not tossing and dying and as a non-typical. NET enthusiast, directly mounted on the mono framework and monodevelopide, to try out cross-platform. NET development. Just recently in the detailed study of the ASP. NET MVC framework, take this to the axe. Open Monodevelopide and select the ASP. NET MVC 3 (Razor) template to create a new project.

Now that the project created from the template is ready, let's run it and try the results.

Actually error, this is what situation. Study the error message and find that there is a problem with the reference to the Assembly in the project. Open the project's References directory inside the IDE and discover that the System.Web.Helpers and System.Web.WebPages Two references are marked red.

Seems to be really a problem ah, can only slowly solve.

Installing NuGet

The cause of this error is actually an MVC packet-dependent error. Said. NET package management, it must have NuGet package Manager. In the mono environment we can also install the NuGet Package Manager to manage dependencies among the individual packages.

Open Monodevelpide, select add-in Manager in the menu to open the Plugins manager.

Select the Gallery tab and select Manage repositoriesfrom the Repository drop-down menu.

Add the http://mrward.github.com/monodevelop-nuget-addin-repository/4.1/main.mrep to the Url text box, Click OK and wait for the operation to complete.

Expand IDE Extensions, and select Install NuGet package Management.

Installing ASP. NET MVC

After installing the NuGet Package Manager, we can use it to download and install the MVC framework.

Open the NuGet Package Manager.

Search ASP. NET MVC, select and install.

The following error may occur in this place, causing the installation to be incomplete.

The reason for this is that the project is now built on. NET 4.0, and the package installation is in the. NET 4.5 environment, so we need to change the project dependencies. NET version.

Once the installation is complete, we look back at the References directory in the project, and all references should be no problem at this time.

Modify Configuration

Rerun the project and find that there are errors, but the error message has changed.

Analyze this error and it should look like a configuration error. Open the project root directory under the Web. config file, based on the error message, let's search the next webpages to see what's in it. The results of the search are displayed in a total of three webpages keywords in the configuration file.

     <add namespace="System.Web.WebPages" />           <add key="webpages:Version" value="1.0.0.0" />     <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />     <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />

Obviously the version number in the second row has been incorrectly changed from <add key= "webpages:version" value= "1.0.0.0" /> to <add key= "webpages: Version "value=" 3.0.0.0 "/>.

Then run the program again, there are errors, and the error message has changed.

This error seems to be a misconfiguration. Search the entire solution for the mvcwebrazorhostfactorymentioned in the error message and find another configuration in the Web. config file under the View folder.

     

Review the Web. config file under the project root directory, where the version configuration for SYSTEM.WEB.MVC is.

 <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-5.1.0.0" newVersion="5.1.0.0" />

So will

Results

To finish the above steps, we'll run the project again.

Finally, the ASP. NET MVC Project environment in Mono is built.

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.