最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi

最新版CentOS6.5上安装部署ASP.NET MVC4和WebApi

  • 使用Jexus5.8.1独立版 http://www.linuxdot.net/ ps:该“独立版”支持64位的CentOS 6.5、Ubuntu 12.04以上版本的操作系统,能运行WebForm、Mvc3-5、WebService 以及WebApi,支持PHP,支持OWIN,支持反向代理,也就是说,无需安装mono的“独立版”与需要安装mono的“通用版”在功能上是完全相同的。

    1. 下载 cd /tmp wget http://www.linuxdot.net/down/jexus-5.8.1-x64.tar.gz

    2. 解压 tar -zxvf jexus-5.8.1-x64.tar.gz

    3. 移动 mv jexus /usr/local

    4. 测试 在/var/www/default/ 用vim新建一个简单index.apsx<%@Page Language="c#" %><%=DateTime.Now.ToString()%>

  • Jexsus常用命名

    1. 启动 ./jws start

    2. 重启 ./jws restart

    3. 停止`./jws stop`

    4. 启动某个网站 start 网站名

    5. 重启某个网站 restart 网站名

    6. 关闭某个网站 stop 网站名

  • 使用vs2013新建一个基本mvc4项目

    1. 修改引用Microsoft.Web.Infrastructure 复制本地设为False

    2. 新建HomeController和View/Home/Index.chstml (重要,不新建是没有默认页面异常:System.Web.HttpException)

    3. 新建ApiTestController(可选)

    4. 修改配置文件(重要)

      <?xml version="1.0" encoding="utf-8"?>
      <!--
        有关如何配置 ASP.NET 应用程序的详细信息,请访问
        http://go.microsoft.com/fwlink/?LinkId=169433
        -->
      
      <configuration>
        <appSettings>
          <add key="webpages:Version" value="2.0.0.0" />
          <add key="webpages:Enabled" value="false" />
          <add key="PreserveLoginUrl" value="true" />
          <add key="ClientValidationEnabled" value="true" />
          <add key="UnobtrusiveJavaScriptEnabled" value="true" />
        </appSettings>
      
        <runtime>
      
          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      
            <dependentAssembly>
      
              <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
      
              <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      
            </dependentAssembly>
      
            <dependentAssembly>
      
              <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
      
              <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      
            </dependentAssembly>
      
            <dependentAssembly>
      
              <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
      
              <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      
            </dependentAssembly>
      
            <dependentAssembly>
      
              <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
      
              <bindingRedirect oldVersion="1.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      
            </dependentAssembly>
      
            <dependentAssembly>
      
              <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" />
      
              <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      
            </dependentAssembly>
      
          </assemblyBinding>
      
        </runtime>
      
        <system.web>
      
           <customErrors mode="Off"/>
          <pages>
            <namespaces>
              <add namespace="System.Web.Helpers" />
              <add namespace="System.Web.Mvc" />
              <add namespace="System.Web.Mvc.Ajax" />
              <add namespace="System.Web.Mvc.Html" />
              <add namespace="System.Web.Routing" />
              <add namespace="System.Web.WebPages" />
            </namespaces>
          </pages>
        </system.web>
      
        <system.webServer>
          <validation validateIntegratedModeConfiguration="false" />
      
        <handlers>
            <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
            <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
            <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
            <add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
            <add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
            <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
          </handlers></system.webServer>
      </configuration>
      

        

推荐 IT网站导航 www.5203.pw

上一篇:如何在Ubuntu/CentOS上安装Linux内核4.0


下一篇:ZKWeb网页框架2.1正式发布