abenci
abenci

Reputation: 8651

Static pages in ASP.NET MVC

Suppose that your ASP.NET MVC website contains a handful of dynamic pages and a big amount of static pages that of course need the Login & Register link on the top right corner. How do you handle this?

We have converted the HTML pages to ASPX and introduced the ASP.NET code to display the user name but I am not sure that it's the best approach. In addition we needed to move static pages to a different folder to avoid collision with MVC routing.

Is this the best that can be done?

Thanks.

Upvotes: 4

Views: 1628

Answers (4)

Sam
Sam

Reputation: 15771

Have you considered some client side script that loads the username/password section you need?

You could have it load a view and inject it into a div. Then you have a single point to maintain for all the static content.

Upvotes: 0

Massimo Zerbini
Massimo Zerbini

Reputation: 3191

If you use IIS Form Athentication for your site static content can be accessed only if the user is authenticated, so you can mantain HTML files and do not convert them in ASPX, but you need to add some javascript to hide the login link and display username (you can check the auth cookie of IIS or create your custom cookie).

Upvotes: 0

Chandermani
Chandermani

Reputation: 42669

I believe as long you implement Donut caching within the ASP.Net pages you can get similar performance as static html pages.

Upvotes: 0

tugberk
tugberk

Reputation: 58444

ASP.NET MVC and Web Forms can live together with no problem. If your approach is working out for you then it should be fine.

Also see the below article. It might help :

Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications

http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx

Upvotes: 1

Related Questions