2011-07-19 48 views
0

內的app_code功能,這是我在web.config中使用的代碼:ASP.NET C#:我怎麼能說的web.config

<add name="MainRule" virtualUrl="^~/Pages/([\w-_]+).html" 
    rewriteUrlParameter="ExcludeFromClientQueryString" 
    destinationUrl="~/page.aspx?pid=${PageTitleToId.ConvertPageTitleToPageId($1)}" 
    ignoreCase="true" /> 

在App_Code文件夾中我有一個「PageTitleToId.cs」包含帶有字符串參數的ConvertPageTitleToPageId函數的類。

我錯過了什麼,因爲ConvertPageTitleToPageId函數在我運行頁面時沒有被調用。

任何幫助表示讚賞,

Simplecode

回答

3

你不能在你的web.config執行代碼。我會更新page.aspx以處理title查詢字符串參數,它在其上調用ConvertPageTitleToPageId()以獲取您的pid