self hosting asp.net mvc

落爺英雄遲暮 提交于 2019-11-26 08:08:31

问题


Is it possible to self host asp.net mvc inside another application ie. console, windows forms, service etc etc.

I\'d like to build an app that offers a web interface to control it and I\'d like to use asp.net mvc for the web part of it.

I did take a quick look at Nancy which looks like it would work, though its not asp.net mvc it did support razor although it doesn\'t have quite the same level of support for it as asp.net (eg. strongly typed views)

I did also find this question but it doesn\'t really go into much depth Possible to use ASPNET MVC2 without IIS?


回答1:


You can use "IIS 7.0 Hostable Web Core" and host the web server as part of any user process, even a console application. The benefit is that it is very similar to full blown IIS (incl config etc) but the web server itself is running in your process.

Have a look at the following articles:

  1. Host your own Web Server in your application using IIS 7.0 Hostable Web Core
  2. Creating Hosted Web Core Applications



回答2:


Please have a look at http://cassinidev.codeplex.com/ It has many advantages for example

  • No need IIS 7 on client machine
  • Support MVC (I have tested myself)
  • Work well with Windows Form and Web Browser Control for packaging as Windows App
  • Cross Win OS platform ( Windows XP, Vista, 7) I have test XP with .NET 4 installed

Hope this helps.




回答3:


I know this question is old, but it is still relevant, so with the .NET Core 1.0 + ASP.NET MVC 6 you can self-host your MVC application easily. You can even combine MVC and WebAPI applications into one, and you can decide later if you want to use IIS, IIS Express or the self-hosting feature of the .NET Core.

You can try it if you follow the Yeoman approach from this post: https://stackoverflow.com/a/30314393/980247



来源:https://stackoverflow.com/questions/10378966/self-hosting-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!