如何将ASP.NET MVC应用程序发布到免费主机

时间:2011-02-18 18:01:33

标签: asp.net-mvc publish publishing

我正在构建一个ASP.NET MVC应用程序,我正在尝试将它部署在支持ASP.NET的免费主机(0000free)上。我尝试了一些东西,但没有一个工作(即我浏览我的网站时只看到目录结构):

  1. 发布到本地文件夹,然后通过ftp将发布的文件复制到我的主机(在public_html目录中)。
  2. 通过ftp发布到根文件夹:ftp.mywebsite.com
  3. 通过ftp发布到public_html文件夹:ftp.mywebsite.com/public_html
  4. 通常我只是将html文件放在public_html文件夹中,但我感觉MVC应用程序的部署过程略有不同。我是否必须修改Web.config或其他文件管理器?如何通常部署MVC应用程序(在免费主机上)?

    更新
    我了解到主机使用Mono并支持.NET 4.0,但我仍然无法部署。

    我有Visual Studio 2010并且我使用了它的发布功能(即右键单击项目名称并单击发布),我尝试了几件事:

    1. 发布方法:FTP到根文件夹。
    2. 发布方法:FTP到publich_html文件夹。
    3. 发布方法:文件系统到根文件夹。
    4. 发布方法:将文件系统发送到publich_html文件夹。
    5. 发布方法:文件系统到我的计算机上的本地目录,然后FTP到root,并尝试了public_html文件夹。
    6. 我进入cPanel(控制面板)尝试查看是否必须为我的网站添加/启用ASP.NET,但我没有看到任何内容。
    7. 我无法浏览到Index.aspx,也无法从index.html重定向到它(正如host forum上的其他帖子所建议的那样),现在我有一个从index.html到Index的链接。 aspx但它也没有工作(见http://www.mydevarmy.com
    8. 我也尝试将Index.aspx重命名为Default.aspx,但这也不起作用。
    9. 主持人论坛的搜索实用程序有点弱,所以我使用谷歌搜索他们的论坛:http://www.google.com/search?q=publish+asp.net+site%3A0000free.com%2Fforum%2F&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

      我一直在阅读Pro ASP.NET MVC Framework,他们有一章关于出版,但它没有提供有关出版地点的任何具体信息,这就是他们所说的(这对他们来说并不是很有帮助)我的情况):

        

      我应该把我的申请放在哪里?
        您可以将您的应用程序部署到任何   服务器上的文件夹。当IIS第一次   安装,它会自动创建一个   名为Default的网站的文件夹   网站位于c:\ Inetpub \ wwwroot \,但是   你不应该有任何义务   把你的应用程序文件放在那它的   在a上托管应用程序非常常见   不同的物理驱动器   操作系统(例如,在   e:\ websites \ example.com)。它的   完全取决于你,也许是   受到诸如你如何关注的影响   计划备份服务器。

      以下是我尝试查看Index.aspx页面时出现的错误:

      Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1)
      
      Description: HTTP 500. Error processing request.
      
      Stack Trace:
      
      System.Configuration.ConfigurationErrorsException: Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1)
        at System.Configuration.ConfigurationElement.DeserializeElement (System.Xml.XmlReader reader, Boolean serializeCollectionKey) [0x00000] in <filename unknown>:0 
        at System.Configuration.ConfigurationSection.DoDeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
        at System.Configuration.ConfigurationSection.DeserializeSection (System.Xml.XmlReader reader) [0x00000] in <filename unknown>:0 
        at System.Configuration.Configuration.GetSectionInstance (System.Configuration.SectionInfo config, Boolean createDefaultInstance) [0x00000] in <filename unknown>:0 
        at System.Configuration.ConfigurationSectionCollection.get_Item (System.String name) [0x00000] in <filename unknown>:0 
        at System.Configuration.Configuration.GetSection (System.String path) [0x00000] in <filename unknown>:0 
        at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path, System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
        at System.Web.Configuration.WebConfigurationManager.GetSection (System.String sectionName, System.String path) [0x00000] in <filename unknown>:0 
        at System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection (System.String sectionName) [0x00000] in <filename unknown>:0 
        at System.Web.Compilation.BuildManager.get_CompilationConfig () [0x00000] in <filename unknown>:0 
        at System.Web.Compilation.BuildManager.Build (System.Web.VirtualPath vp) [0x00000] in <filename unknown>:0 
        at System.Web.Compilation.BuildManager.GetCompiledType (System.Web.VirtualPath virtualPath) [0x00000] in <filename unknown>:0 
        at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] in <filename unknown>:0 
        at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 
      

2 个答案:

答案 0 :(得分:7)

如果您的托管服务提供商支持ASP.NET MVC,那么您的部署过程应该与普通ASP.NET应用程序的过程不同。如果不是,您可以尝试bin-deployment。这是MSDN上的another article

答案 1 :(得分:1)

事实证明Mono版本不支持MVC,因此我不得不将主机更改为支持ASP.NET MVC的主机。我不得不提供一些现金,但“好主机”不是免费的。无论如何,感谢大家的帮助!