0

So I just got a site hosted at hostasp.net. In VS I'm working with a web site not a web application. In the control panel on the host under my site I have folders (data, logs, wwwroot). My current project only has 1 javascript file, 1 aspx page, and a web.config. I placed Default.aspx & web.config directly under wwwroot. In VS my javascript file is in a subfolder named Scripts so I created this subfolder on the host site and placed my javascript file in there.

When I access my site I get "Server Error in '/' Application." error. What am I messing up here?

Also if I have a code behind file, where do I put that? Should it be compiled somehow? When I built the VS project it doesn't give me any dll for it or anything. Right now I don't have anything in the code behind but just wondering for later if I do.

user441521
  • 6,942
  • 23
  • 88
  • 160
  • You should post the exact error. It probably contains more detail. My best guess is that your aspx page still has a reference to your aspx.cs file, so you need to include it. – Khan Nov 29 '12 at 20:35
  • 1
    Check this answer and after find the real issue you may solve it alone: http://stackoverflow.com/questions/5385714/deploying-website-500-internal-server-error/5385884#5385884 – Aristos Nov 29 '12 at 20:36
  • Oh that's slick. It says it failed when trying to process the using line to access linq. So I did put the code behind file under wwwroot. Is that OK? People can't get to that can they? Taking out linq worked btw. Not sure why it doesn't let me access linq though. Will have to talk with the host. – user441521 Nov 29 '12 at 20:39
  • In ASP.NET Applications, "Code behind" classes are compiled and you only upload the binary DLL files, never the source code. Are you using "ASP.NET Websites" instead? – Dai Nov 29 '12 at 21:06

1 Answers1

0

If you are using Visual Studio:

  • You can certainly just copy the files to your live server. Your "code behind" files will be compiled at run time.
  • You can Publish a Web Site or Web application so you have the option to pre-compile (to dll) all your code (and will be in /bin folder).

If you want to remove the "guessing" of which files you need to "push" to your live server. You can publish to your local file system or directly to FTP. VS will pre-compile your Web Site or Web Application, and "collect" all the necessary files that make up your web site/application and save it in the folder/FTP site you designate.

If you chose to publish to file system, then all you have to do is copy/ftp (whatever) to your live site. You might ask why even publish to local (first) only to FTP it anyway? So you can get fully acquainted with how all of this works - the different publish options, etc. locally (which is essentially the exact structure of your production site).


Publish Web Site (VS):

Publish Web Site screenshot


Publish Web Application (VS):

publish web application


The only time this may not work is when your host doesn't have the "bits" that you might have. E.g. not all hosts may have the latest/greatest from Microsoft, like say, Web API and all the assemblies it entails.

But again, the tooling can help with Add Deployable Dependencies...which does and when you publish, the dependencies are all "bin deployed" (meaning they'll be in the /bin folder):

Add deployable dependencies screenshot

Hth...

EdSF
  • 11,753
  • 6
  • 42
  • 83