RoundOutTooSoon
RoundOutTooSoon

Reputation: 9891

ASP.NET C#: How can I call App_code functions inside of web.config

This is the code I use in the 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.

Am I missing something because the ConvertPageTitleToPageId function is not called when I run the page.

Any help is appreciated,

Simplecode

Upvotes: 0

Views: 1249

Answers (1)

dahlbyk
dahlbyk

Reputation: 77590

You can't execute code in your web.config. I would update page.aspx to handle a title query string parameter on which it calls ConvertPageTitleToPageId() to get your pid.

Upvotes: 3

Related Questions