我正在构建一个 ASP.NET MVC 应用程序,并试图将它部署到一个支持 ASP.NET 的免费主机 (0000free) 上。我尝试了几件事,但都没有奏效(即,我只在浏览我的网站时看到目录结构):
- 发布到本地文件夹,然后通过 ftp 将发布的文件复制到我的主机(在 public_html 目录中)。
- 通过 ftp 发布到根文件夹:ftp.mywebsite.com
- 通过 ftp 发布到 public_html 文件夹:ftp.mywebsite.com/public_html
通常我只是将 html 文件放在 public_html 文件夹中,但我感觉 MVC 应用程序的部署过程略有不同。我是否必须修改 Web.config
或其他一些文件管理器?人们通常如何部署 MVC 应用程序(在免费主机上)?
更新:
我了解到主机使用 Mono 并支持 .NET 4.0,但我仍然无法部署。
我有 Visual Studio 2010,我使用了它的发布功能(即右键单击项目名称并单击发布),我尝试了几种方法:
- 发布方式:FTP到根文件夹。
- 发布方法:FTP 到 publicich_html 文件夹。
- 发布方法:文件系统到根文件夹。
- 发布方法:文件系统到 public_html 文件夹。
- 发布方法:文件系统到我电脑的本地目录,然后通过 FTP 到 root,也尝试了 public_html 文件夹。
- 我进入 cPanel(控制面板)尝试查看是否必须为我的网站添加/启用 ASP.NET,但我在那里没有看到任何东西。
- 我无法浏览到 Index.aspx,也无法从 index.html 重定向到它(如 host forum 上的其他帖子所建议),现在我有一个从 index.html 到 Index.aspx 的链接,但是它也不起作用(参见 http://www.mydevarmy.com)
- 我也试过将 Index.aspx 重命名为 Default.aspx,但这也不起作用。
楼主论坛的搜索功能有点弱,所以我用google搜索他们的论坛: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他们有一个关于出版的章节,但它没有提供任何关于出版地点的具体信息,这就是他们所说的(对我来说这不是很有帮助):
Where Should I Put My Application?
You can deploy your application to any folder on the server. When IIS first installs, it automatically creates a folder for a web site called Default Web Site at c:\Inetpub\wwwroot\, but you shouldn’t feel any obligation to put your application files there. It’s very common to host applications on a different physical drive from the operating system (e.g., in e:\websites\ example.com). It’s entirely up to you, and may be influenced by concerns such as how you plan to back up the server.
这是我在尝试查看我的 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
最佳答案
如果您的托管服务提供商支持 ASP.NET MVC,那么您的部署过程应该与普通 ASP.NET 应用程序没有任何不同。如果没有,您可以尝试 bin-deployment .这是another article在 MSDN 上。
关于asp.net-mvc - 如何将 ASP.NET MVC 应用程序发布到免费主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5044854/