Generating a Webpage When It doesn't Exist

46 views Asked by At

How can I generate a webpage based on users request? for example, If someone wants to visit "www.mywebsite.com/example" and there is no such url, My website will generate him/her a webpage based on word "example". How can I do it? (I'm developing my website by ASP.NET)

1

There are 1 answers

3
Benjishk On

One way to process such a page is to use ASP.NET attribute routing.

[Route("{pageName}")]
public ActionResults myActionName(String pageName)
{

// in this action method you process what you need to do to 

// figure out what you need to generate base to push to user.

//------

// either make a generic view and fill with your content or 

// generate the view code on the fly.

// you can also send view to user from a DB.

 return view();
}

for webforms check: https://msdn.microsoft.com/en-us/library/cc668177(v=vs.140).aspx