如何在远程服务器上设置asp.net Web应用程序

时间:2012-08-16 13:45:46

标签: asp.net asp.net-mvc-3 iis web-applications razor

更新: 这是服务器上的指令。但按照此说明,我找不到选项"连接到网站"

enter image description here


我是ASP.NET MVC 4和Razor的新手。现在我已经完成了我的ASP.NET Web应用程序,我希望将其上传到服务器并使其可供公众访问。

以前,我只是直接使用FX FTP创建网站并将其上传到WebCentral(http://www.webcentral.com.au/),并且可以立即访问这些网站。

我已检查过WebCentral服务器是否具有.NET Framework 4.0版本。

现在我想探索MVC4和Razor以及Entity Framework的新进展,我选择了ASP.NET MVC 4 Web应用程序。将此新Web应用程序上载到服务器后,显示错误:

Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.  This error can be caused by a virtual directory not being configured as an application in IIS.

Source Error: 


Line 22:   <system.web>
Line 23:     <compilation debug="true" targetFramework="4.0" />
Line 24:     <authentication mode="Forms">
Line 25:       <forms loginUrl="~/Account/Login" timeout="2880" />
Line 26:     </authentication>

Source File: \\n5200-2\iis7_www\z\a\zanity.com.au\www\ce\web.config    Line: 24 

我不知道如何解决此错误。 如果您知道如何解决这个问题,请帮助我。

非常感谢。

这是Web.configure文件

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<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=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" providerName="System.Data.SqlClient" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=aspnet-MVCTry-20120813175505;Integrated Security=SSPI" />
  </connectionStrings>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <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>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
    <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.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </roleManager>
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
  <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>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

1 个答案:

答案 0 :(得分:0)

更新: 我最近发现IIS管理概述下的WebCentral Mission Control面板上有一个选项: 1.选择“Web应用程序”文件夹 2.在右侧面板上选择“设置” 3.单击“安装应用程序”部分下的“安装”以在所选文件夹上安装应用程序。

通过执行此操作,所选文件夹将成为Web Application文件夹,然后我可以将bin和App_Code和App_Data文件夹放在Web Application文件夹下。

我终于明白了。

原因是我没有将bin和App_Code文件夹放在正确的方向上。 在WebCentral Web服务器上,Web.config文件和App_Code文件夹应放在当前项目文件夹下,而bin文件夹应放在/ wwwroot文件夹下。

我将所有依赖项复制到bin文件夹。

这解决了所有问题。

我很高兴知道只要在bin文件夹中提供了嵌套DLL,我就可以在这个Web服务器上运行最新版本的ASP.NET MVC 4和Razor。

干杯:)

相关问题