views:

88

answers:

2

Hi! I'm about to create quite simple website which will contain several static pages (they will never change) and one dynamic change (let's call it news). I'was wondering whether it's possible to use MVC here without having to create controllers and views for these "static" pages. Isn't that just too much overhead?

Is there a way to make MVC simply route incoming requests to valid documents without actually having to create controller?

+6  A: 

Just put your static content in a separate directory and link to it there. ASP.NET will simply serve up the static content as normal when the path is to a actual file. I created a static folder in my Content folder, but you could put it anywhere. The files could even live in the root of the site.

   +-Content
     +-images
     +-static
       +-about.html
       +-info.html
     +-styles
       +-site.css
       +-themes
        ...
tvanfosson
does that also applies if i have 'static' aspx file? Cause I'm having some problems with that.. (thanks for reply!)
StupidDeveloper
ok, It's working, thanks!!
StupidDeveloper
A: 

For "static" aspx files, you would need to wire up a route (or use the default catch all) to something like:

public ActionResult(string pageName)
{
    return View(pageName);
}

And that should let someone make views in the appropriate folder and then have them be added and or executed on the fly.

Wyatt Barnett