Geeks With Blogs
expression{} Thoughts on Expression Web and web tools in general

There’s no immediately obvious way to use an include on an ASP.Net Web Page and most of the time you will probably do everything you need using a layout page.

I recently had an application where I used some code at the top of each page, many not based on the site template, to check for user authentication and a number of user roles. This code changed several times with customer needs and it seemed having an include for the code would be a better solution.

After hunting around I found it was possible, using the @RenderPage method.

So, I put my complete code block, including opening and closing @code ‘tags’, in a file I called ‘_incCode.cshtml’. This is then called at the top of each page not using the template, using:


Posted on Monday, March 10, 2014 11:55 PM ASP.NET Razor , Web Matrix | Back to top

Related Posts on Geeks With Blogs Matching Categories

Comments on this post: Using ‘includes’ in ASP.Net Web Pages

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © ihaynes | Powered by: