Dynamically Create ASP.NET Content Pages
Asked Answered
J

4

6
  • Is it possible with ASP.NET Master Pages to create content pages dynamically? That is, I know we can create content dynamically, but the content pages themselves, can those be created programmatically? I want to give my users the ability to define new content pages (i.e. Categories: Sofas, Tables, Lamps, and add/delete as they see fit) through a management panel. The resulting content pages should have proper URL naming, so that they index properly. An example: http://www.example.com/products/Lamps/contentpage.aspx.
  • Is there a demonstration of this somewhere I can view?
Jennee answered 22/1, 2010 at 19:41 Comment(2)
Is there a reason you simply can't take advantage of URL rewriting so that the example URL you've given actually serves a typical dynamic content page?Jacklynjackman
With URL rewriting or routing you don't need actual aspx files to get proper URLs. I think you should probably look into this before you start generating aspx files.Cellulous
E
3

Your question is something people struggled alot back then, but these days are much better with a few technologies.

ASP.NET MVC to the rescue! With that, you can have your friendly URLs map to your dynamically created content, so if a user creates a new "Lamp" in the "Products" category, it will be accessed via http://yourhost/Products/Lamp

ASP.NET MVC uses the .NET Routing to accomplish those URLs, and you can use that without a ASP.NET MVC itself if your project have those restrictions. If you cannot use .NET 3.5, go with another URL rewrite tech.

Exstipulate answered 22/1, 2010 at 21:24 Comment(7)
Yes, ASP.NET Mvc is great for this purpose.Libnah
@F.Aquino, are you saying this cannot be accomplished with Web forms?Denunciate
Answer is spot on what I want to do. Thanks. Going to start with this blog entry: weblogs.asp.net/scottgu/archive/2007/12/03/… and see where it takes me.Jennee
@IrishChieftain, it can be acomplished with machine code, is that really the point?Exstipulate
@F.Aquino, genuinely I want to know if it's much more painful with forms because I haven't done it myself :-)Denunciate
With web forms, you could use a UrlRewriter (I like the Helicon mod_rewrite clone for IIS) or use the VirtualPathProvider I suggested below.Wyeth
@Denunciate -- Oh, alright then, you sounded like a troll in my devastated-by-internet ears :) the URL Routing link has that exact concept going, on how to use it without MVC. Before, we used a multitude of URL Rewriting HttpModules to get near that type of Apache mod_rewrite magic but it was complicated to say the least.Exstipulate
W
1

Writing .aspx files into your web's folders seems like a serious security risk. If you want users to create their own pages, you might want to store this information in a database and use a VirtualPathProvider to serve up these files to the ASP.NET engine.

Wyeth answered 22/1, 2010 at 21:15 Comment(0)
C
0

You could use the TextWriter class and create all the pages and code behinds you want. That would be a pain forsure but it would work, although i've never done it before, you might run into some issues since it wouldnt be compiled. you can definitely make html static pages

Chinookan answered 22/1, 2010 at 19:44 Comment(1)
Pages are compiled and cached the first time they are requested.Jennee
S
0

If you are looking to build your own, that would be a very tedious job. It would be better to purchase or use an open source content management system to do the job. There are many on the market that are available to you in both categories. This is the primary feature for this type of software package.

Check out www.codeplex.com for some, or there are others to buy like Telligent's package or Telerik's Sitefinity.

Shandy answered 22/1, 2010 at 20:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.