0

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)

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Amir
  • 11
  • 2

1 Answers1

-1

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

Benjishk
  • 51
  • 1
  • 3
  • True. Routing can be used with Web Forms, but not like that. – John Saunders Jun 18 '15 at 22:07
  • @sushil it is MVC, you can set the attribute routing for webforms as follow, but i haven't use webforms in the past 3 years. so i won't be able to comment. please check the following link [link to Microsoft routing page](https://msdn.microsoft.com/en-us/library/cc668177(v=vs.140).aspx) – Benjishk Jun 18 '15 at 22:08
  • @Benjishk I meant the action result – Sushil Jun 18 '15 at 22:29