简体   繁体   English

ASP.NET MVC部署到iis不会自动编译

[英]ASP.NET MVC deploy to iis not auto compile

I have an ASP.NET(Framework4.6.1) MVC project, If I deploy to IIS is the entire project,It can work. 我有一个ASP.NET(Framework4.6.1)MVC项目,如果我将整个项目部署到IIS,它将可以正常工作。 But If I only change some .cs or .cshtml files,iis won't recompile 但是,如果我仅更改某些.cs或.cshtml文件,则iis将不会重新编译

I want to ask: Can I just change some of the .cs or .cshtml files to allow iis to be recompiled instead of uploading the entire project each time? 我想问一下:我可以只更改某些.cs或.cshtml文件以允许iis重新编译,而不是每次都上载整个项目吗?

My system information 我的系统信息

  1. ASP.NET(Framework4.6.1) MVC project ASP.NET(Framework4.6.1)MVC项目
  2. EntityFramework,Version=6.0.0.0 EntityFramework,Version = 6.0.0.0
  3. IIS 7.5 integration IIS 7.5集成

web.config web.config

 <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <appSettings>
        <add key="webpages:Version" value="3.0.0.0" />
        <add key="webpages:Enabled" value="false" />
        <add key="ClientValidationEnabled" value="true" />
        <add key="UnobtrusiveJavaScriptEnabled" value="true" />
        <add key="SessionTimeout" value="6000" />

      </appSettings>
      <system.web>
        <customErrors mode="Off"/>
        <compilation debug="true" targetFramework="4.6.1" />
        <httpRuntime targetFramework="4.6.1" maxRequestLength="102400" />
        <httpModules>
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
        </httpModules>

      </system.web>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
            <bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <modules>
          <remove name="ApplicationInsightsWebTracking" />
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
        </modules>

      </system.webServer>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:1659;1699;1701" />
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:default /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
      </system.codedom>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>

    </configuration>

.cs - You could just upload the DLL file, if the changes are very minimal. .cs如果更改很小,则可以仅上传DLL文件。

.cshtml - You just copy and replace the individual file in IIS assuming you don't modify the corresponding controllers. .cshtml您只需复制并替换IIS中的单个文件,前提是您不修改相应的控制器。

You might want to look at web deploy which deploys only the necessary files instead of entire application. 您可能要看一下Web部署,它仅部署必要的文件而不是整个应用程序。

Can I just change some of the .cs or .cshtml files to allow iis to be recompiled instead of uploading the entire project each time? 我可以只更改某些.cs或.cshtml文件以允许iis重新编译,而不是每次都上传整个项目吗?

If you open the web.config file in notepad and just click File > Save or just copy and replace the same web.config file, then IIS will recompile the application. 如果在记事本中打开web.config文件,然后单击“ File > Save或者仅复制并替换相同的web.config文件,则IIS将重新编译该应用程序。

Note: Replacing .cshtml file doesn't require the application to be recompiled. 注意:替换.cshtml文件不需要重新编译应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM