开发者

How to publish an ASP.NET MVC application to a free host

开发者 https://www.devze.com 2023-02-12 11:02 出处:网络
I\'m building an ASP.NET MVC application and I\'m trying to deploy it on a free host (0000free) which does support ASP.NET. I tried a couple of things, but none of them worked (i.e. I only see the dir

I'm building an ASP.NET MVC application and I'm trying to deploy it on a free host (0000free) which does support ASP.NET. I tried a couple of things, but none of them worked (i.e. I only see the directory structure when I browse to my web site):

  1. Publishing to a local folder and then copying the published files via ftp over to my host (in the public_html directory).
  2. Publishing via ftp to the root folder: ftp.mywebsite.com
  3. Publishing via ftp to the public_html folder: ftp.mywebsite.com/public_html

Usually I would just drop the html files in the public_html folder, but I'm getting the feeling that the deployment process for an MVC application is slightly different. Do I have to modify the Web.config or some other filer? How does one usually deploy an MVC application (on a free host)?

Update:

I have learned that the host uses Mono and supports .NET 4.0, but I'm still not able to deploy.

I have Visual Studio 2010 and I used its Publish Feature (i.e. right click on the project name and click publish) and I tried several things:

  1. Publish method: FTP to the root folder.
  2. Publish method: FTP to the publich_html folder.
  3. Publish method: File System to the root folder.
  4. Publish method: File System to the publich_html folder.
  5. Publish method: File System to a local directory on my computer and then FTP to root and also tried the public_html folder.
  6. I went into the cPanel (control panel) to try and see if ASP.NET has to be added/enabled for my web site, but I didn't see anything there.
  7. I can't browse to Index.aspx nor can I redirect to it from index.html (as suggested from other posts on the host forum), right now I have a link from index.html to Index.aspx but it's not working either (see http://www.mydevarmy.com)
  8. I've also tried renaming Index.aspx to Default.aspx, but that doesn't work either.

The search utility of the forum of the host is somewhat weak, so I use google to search their forum: 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

I've been reading Pro ASP.NET MVC Framework and they have a chapter about publishing, but it doesn't provide any specific information with respect to the location of publishing, this is all they say (and it's not very helpful in my case):

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.

Here is the error I get when I try to view my Index.aspx page:

Unrecognized attribute 'targetFramework'. (/home/devarmy/public_html/Web.config line 1)

Description: HTTP 500. Error processing request.

Stack Trace:

System.Configuration.ConfigurationErrorsException: Unrecogniz开发者_运维知识库ed 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 


If your hosting provider supports ASP.NET MVC then your deployment process shouldn't be any different than the one for a normal ASP.NET application. If it doesn't you could attempt a bin-deployment. And here's another article on MSDN.


It turns out that the Mono version does not support MVC, so I had to change my host to one that supports ASP.NET MVC. I had to dish out some cash, but "good hosting" isn't free. Anyway, thanks for the help everybody!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号