Guide to Setting Up Basic Site Programmatically

I am brand new to ASP.NET though not programming. I have been looking for a guide regarding set-up of a basic, single controller site. All I have come across are things involving the the visual studio IDE. However, I would like to manually go through the steps of creating a ASP.NET site.

That said, I after listening to several videos and combination with my familiarity to everything else I have tried some things. How close I am not sure but perhaps someone could help me out or point me to a good resource involving manual setup.

Anyway, In my web root I created two directories: Controllers and Views. In the Controller directory I create the file HomeController.cs. Inside the Views directory I created sub-directory called Home. Within that directory I created a file called Index.cshtml. So my directory structure is as follows:

/

  • Controllers
    — HomeController.cs
  • Views
    — Home
    ----- Index.cshtml

I than compiled HomeController.cs to yield an executable (that seems right). Now, when I go to: http://localhost:8080/Home/Index it yields a resource not found error. I can only assume that I missed a gigantic step and would appreciate it if someone could point me in the right direction.

btw: I am on a mac using the mono framework. I have tested that the mono install works and its properly functioning using the hello world examples.

thanks

Building an ASP.NET site without Visual Studio is sort of like building a car with a rock. Both sound a bit frustrating.

You can still go through the steps manually using VS. As opposed to what though, I don’t know, do you mean typing every character instead of using the intellisense? I’ve owned VS for about 4 years now and I think I’ve only opened the design view a handful of times if that’s what you’re talking about.

If you’ve got one of those fancy new Intel Macs why not install a Windows partition and download Visual Web Developer? Seems prudent.

Judging from your structure I’d assume you’re wanting to use MVC. If so, you’ll need a Global.asax file with a routing table.

MVC is a bit of a trick, but you could do plain old ASPX pages without too much trouble. Just call the files .ASPX and use <script runat=“server”> for the server-side bits. Works quite well in IIS, not sure how to configure it properly in apache.

All that said, given the good free options about these days, I would focus on something different. What you probably want to look at is something like Manos de Mono.

Well after looking at some more videos I learned of the Global.asax file which I added. However, I am now having issues compiling that file.


Global.asax(11,50): error CS0234: The type or namespace name `HttpApplication' does not exist in the namespace `System.Web'. Are you missing an assembly reference?
Global.asax(2,14): error CS0234: The type or namespace name `Collection' does not exist in the namespace `System'. Are you missing an assembly reference?
Global.asax(5,18): error CS0234: The type or namespace name `Mvc' does not exist in the namespace `System.Web'. Are you missing an assembly reference?
Global.asax(6,18): error CS0234: The type or namespace name `Routing' does not exist in the namespace `System.Web'. Are you missing an assembly reference?
Global.asax(21,51): error CS0246: The type or namespace name `RouteCollection' could not be found. Are you missing a using directive or an assembly reference?
Compilation fail

I copied the code for the Global.asax file from a video on pluralsight yet it seems to be producing those errors. I can only assume this has something to do with the mono install omitting a necessary piece of the puzzle of paths being incorrect. any ideas?

Also, I noticed on the error page that the version in use is 2, rather then what I would like is 3. What would be the proper item to add to the Web.config(?) file to use version 3?

Also, you are correct I am trying to use MVC w/ razor.

thanks

In the mono install process I had this issue and resolved it with the symbolic link. I am now thinking that the previously mentioned issue is due to fixing the symptom rather than the actual issue – am I right?