【问题标题】:How do I setup an asp.net web application on a remote server如何在远程服务器上设置 asp.net Web 应用程序
【发布时间】:2012-08-16 13:45:45
【问题描述】:

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


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

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

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

现在我想探索 MVC4 和 Razor 以及实体框架的新进展,我选择了 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>

【问题讨论】:

  • 如果服务器有多个 .Net 版本,您必须进入该网站的应用程序池的属性,并确保将其设置为使用 .Net 4.0 而不是 .Net 2.0 .
  • Joel 的建议是我要检查的第一件事,但仅仅因为安装了 .Net 4.0 并不意味着在服务器上安装了 MVC 4(或任何版本)。
  • @JoelEtherton,我在服务器上购买了一个计划,但我无法完全控制如何配置此服务器。 >_
  • @TimMedora,我只是一个使用其他服务器来托管我的 Web 应用程序的人,所以我无法在其上安装 MVC 4。这是否意味着到目前为止所有 Web 应用程序都在 Internet 上并且没有托管在它们自己的 Web 服务器上不是 MVC Web 应用程序?
  • 您绝对可以找到 MVC 托管...如果您要求,您的主机甚至可以为您安装它。但是,由于 MVC 4 还不是最终版本,您可能必须自己包含所有依赖项,方法是将它们复制到本地 bin。

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


【解决方案1】:

更新: 我最近发现在 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 文件夹中。

这解决了所有问题。

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

干杯:)

【讨论】:

  • 其实你应该把App_Code和bin都放在你的项目文件夹下。然后您需要在 IIS 中将您的项目文件夹标记为应用程序。
  • @jrummell,谢谢你的建议,但它是一个不属于我的网络服务器。我只能上传文件到它。
  • 大多数 Web 主机都允许您访问 IIS 工具,例如应用程序管理。希望您的主机支持它。
  • @jrummell 嗨,Jru,你说的正是我想要的。我的主机支持这个配置,但是它的指令是完全错误的。我将在我的问题中发布屏幕截图,您可以查看并关注它,看看它是否适合您。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-03-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多