[英]ASP.NET C#: How can I call App_code functions inside of web.config
This is the code I use in the web.config:这是我在 web.config 中使用的代码:
<add name="MainRule" virtualUrl="^~/Pages/([\w-_]+).html"
rewriteUrlParameter="ExcludeFromClientQueryString"
destinationUrl="~/page.aspx?pid=${PageTitleToId.ConvertPageTitleToPageId($1)}"
ignoreCase="true" />
In the App_Code folder I have a "PageTitleToId.cs" class which contains the ConvertPageTitleToPageId function which takes a string parameter.在 App_Code 文件夹中,我有一个“PageTitleToId.cs”class,其中包含带有字符串参数的 ConvertPageTitleToPageId function。
Am I missing something because the ConvertPageTitleToPageId function is not called when I run the page.我是否遗漏了什么,因为在我运行页面时未调用 ConvertPageTitleToPageId function。
Any help is appreciated,任何帮助表示赞赏,
Simplecode简单代码
You can't execute code in your web.config.您无法执行 web.config 中的代码。 I would update page.aspx
to handle a title
query string parameter on which it calls ConvertPageTitleToPageId()
to get your pid
.我会更新page.aspx
以处理title
查询字符串参数,在该参数上它调用ConvertPageTitleToPageId()
来获取您的pid
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.