【问题标题】:Generating a Webpage When It doesn't Exist在网页不存在时生成网页
【发布时间】:2015-09-04 17:52:09
【问题描述】:

如何根据用户请求生成网页?例如,如果有人想访问“www.mywebsite.com/example”并且没有这样的 url,我的网站会根据“example”这个词为他/她生成一个网页。我该怎么做? (我正在通过 ASP.NET 开发我的网站)

【问题讨论】:

标签: asp.net url webforms asp.net-routing generated-code


【解决方案1】:

处理此类页面的一种方法是使用 ASP.NET 属性路由。

[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();
}

对于网络表单检查: https://msdn.microsoft.com/en-us/library/cc668177(v=vs.140).aspx

【讨论】:

  • 是的。路由可以与 Web 表单一起使用,但不是这样。
  • @sushil 它是 MVC,您可以为 webforms 设置属性路由如下,但我在过去 3 年没有使用 webforms。所以我无法发表评论。请查看以下链接link to Microsoft routing page
  • @Benjishk 我的意思是行动结果
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-07-07
相关资源
最近更新 更多