c# - How to write new rules from code behined in web.config -
i have applied url rewrite in application , define rules in web.config
<modulessection> <rewritemodule> <rewriteon>true</rewriteon> <rewriterules> <rule source="about/about-test" destination="about/about.aspx"/> <rule source="test-in-media" destination="others/mediaupdates.aspx"/> <rule source="home" destination="masterpage/homepage.aspx"/> </rewriterules> </rewritemodule> </modulessection> <httpmodules> <add name="rewritemodule" type="rewritemodule.rewritemodule, rewritemodule"/> <add name="scriptmodule" type="system.web.handlers.scriptmodule, system.web.extensions, version=3.5.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"/> </httpmodules> ok have found solution..i have used following code snippets..
rewritemodulesectionhandler cfg =(rewritemodulesectionhandler)configurationmanager.getsection("modulessection/rewritemodule"); if (!cfg.rewriteon) return; string path = httpcontext.current.request.path; if (path.length == 0) return; xmlnode xmlnode = cfg.xmlsection.selectsinglenode("rewriterules"); if( xmlnode != null ) { } now how can add new rule in format???
can please more specific type of rule want add or modify?
for changing web .config through application please go through following article.
Comments
Post a Comment