简体   繁体   English

在ASP.Net/C#中自动生成一个新页面/ URL

[英]Automatically generate a new page / URL in ASP.Net / C#

I want to generate a new URL and page when someone submits a form. 当有人提交表单时,我想生成一个新的URL和页面。 Meaning when the button is clicked, a new asp.net page is added to a folder. 这意味着单击该按钮时,新的asp.net页将添加到文件夹中。

I think maybe Routing does this: https://msdn.microsoft.com/en-us/library/dd329551.aspx 我认为也许路由可以做到这一点: https : //msdn.microsoft.com/en-us/library/dd329551.aspx

But is this the way to do it or is there some other tutorial/way to be doing this? 但这是这样做的方式吗,还是有其他一些教程/方式可以做到这一点?

It is not a good practice to create a new aspx page for each page submission. 为每个页面提交创建一个新的aspx页面不是一个好习惯。

But what you have to do is create an aspx page that handles these form submissions, each submission has a different URL or Query string. 但是您要做的是创建一个处理这些表单提交的aspx页面,每个提交都有不同的URL或查询字符串。

You can use the IIS URL Rewrite module. 您可以使用IIS URL重写模块。

check this URL http://www.iis.net/learn/extensions/url-rewrite-module 检查此URL http://www.iis.net/learn/extensions/url-rewrite-module

basically generating a page is not something that can be done by a user. 基本上,生成页面不是用户可以完成的事情。 most of the time routing can be the answer of your question. 大多数情况下,路由可以是您问题的答案。 the parameters that page recieves can have different content based on those parameters. 页面接收的参数根据这些参数可以具有不同的内容。 like beliw: you send parameter by: 像beliw:您通过以下方式发送参数:

Redirect("page.aspx?name=john" );

recieve in other page: 在其他页面收到:

string x= Request.queryString["name"];

it is mostly used in cms systems. 它主要用于cms系统。 for example you just have one news page but the prameter that page recieves says to show which news from database. 例如,您只有一个新闻页面,但是该页面接收到的参数用来显示数据库中的哪个新闻。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM