本文主要对什么是WebConfig?以及其自身特性相关说明和其本身几个主要节点说明,最后举例说明WebConfig在应用程序中的相关应用。
一个东西从无到有,总有其存在的价值和意义!
而对Web.config配置文件来说来说,其主要的作用用来储存ASP.NET Web应用程序作应用程序相关配置信息。什么是配置信息
比如:应用程序身份验证方式、引用程序集、出错后指引、URL重写、Session时期、编码方式等等,一方面方便修改,比如验证图片格式等,另外一方面,方便迁移,比如数据库更改,同时,也方便其他组件进行组合,配置。
本文主要讲述:
1, 配置文件的优先级查找
2, 配置文件节点说明
3, 配置文件的相关应用。
1,配置文件的优先级查找
.net提供呢一个针对当前机器的WinForm程序和Asp.Net应用程序的配置,名字叫machine.config,它位于%windir%/Microsoft.NET/Framework/v2.0.50727/CONFIG/文件中,
Asp.net网站IIS启动的时候,会加载配置文件里面的配置信息,并会缓存这些信息!,一旦在运行过程中Asp.net监视配置文件的变化,一旦编辑呢这些配置文件,就会重新读取这些配置文件信息并且缓存。
当我们要读取某一个配置节点的时候,会按照下面的顺序。
当前页面所在的Web.config,没有返回到上一目录,直到跟目录,如果都不存在该节点获得Web.config文件都不存在,就查找本机器的
%windir%/Microsoft.NET/Framework/v2.0.50727/CONFIG/web.config,如果还没有就查找到%windir%/Microsoft.NET/Framework/v2.0.50727/CONFIG/machine.config,如果都没有就返回null。
2,相关配置节点的解说。
Web.config是一个Xml文件,其主要的节点有
2.1- configSections
指定配置节和命名空间声明。clear:移除对继承的节和节组的所有引用,只允许由当前 section 和 sectionGroup 元素添加的节和节组。remove:移除对继承的节和节组的引用。section:定义配置节处理程序与配置元素之间的关联。sectionGroup:定义配置节处理程序与配置节之间的关联。
2.2appSettings
appSettings是应用程序设置,可以定义应用程序的全局常量设置等信息。
2.3 connectionStrings
连接字符串设置
2.4 system.web
提供页面跳转,身份验证,URL重新声明等
2.5 system.webServer
该节替换在 httpHandlers 和 httpModules 节中添加的与 AJAX 相关的 HTTP 处理程序和模块。该节使 IIS 7.0 在集成模式下运行时可使用这些处理程序和模块。在iis7.0 下运行 ASP.NET AJAX 需要 system.webServer节。对早期版本的 IIS 来说则不需要此节。
2.6 runtime
提供运行时,所需要的版本和名称
以下是一个Web.config的说明
4, 配置文件相关应用
1.获得appSettings和connectionStrings设置的信息
ConfigurationManager.AppSettings[""].ToString();
ConfigurationManager.ConnectionStrings[""].ToString();
其中ConfigurationManager在System.Configuration命名空间里面
2.如何配置用户自定义错误信息,包括404,,403等,就是程序意外报错后,如何处理?
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
其中Mode有三个参数ON,Off,RemoteOnly
On 表示在本地和远程用户都会看到自定义错误信息。
Off 禁用自定义错误信息,本地和远程用户都会看到详细的错误信息。
RemoteOnly 表示本地用户将看到详细错误信息,而远程用户将会看到自定义错误信息。
defaultRedirect属性是一个可选属性,表示应用程序发生错误时重定向到的默认URL,如果没有指定该属性则显示一般性错误
当Mode为On时候,Error定义的节点才会启动
3,如何不让访问某一文件夹里面的内容?
使用<httpHandlers>节点,<httpHandlers>节点用于根据用户请求的URL和HTTP谓词将用户的请求交给相应的处理程序。可以在配置级别的任何层次配置此节点,也就是说可以针对某个特定目录下指定的特殊文件进行特殊处理。
<httpHandlers>
<add path="IPData/*.txt" verb="*" type="System.Web.HttpForbiddenHandler"/>
</httpHandlers>
其中System.Web.HttpForbiddenHandler 表示用户不能查看或者下载相关的文件。
4,如何设置全局编码?
<globalization>节点:
用于配置应用程序的全球化设置。此节点有几个比较重要的属性,分别如下:
属性名 说明
fileEncoding 可选属性。设置.aspx、.asmx和 .asax文件的存储编码。
requestEncoding 可选属性。设置客户端请求的编码,默认为UTF-8.
responseEncoding 可选属性。设置服务器端响应的编码,默认为UTF-8.
以下就是asp.net应用程序中的默认配置:
1. <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8"/>
下面附录常规Web.config的解说。
<?xmlversion="1.0"?>
<configuration>
<!--指定配置节和命名空间声明。clear:移除对继承的节和节组的所有引用,只允许由当前 section 和 sectionGroup 元素添加的节和节组。remove:移除对继承的节和节组的引用。section:定义配置节处理程序与配置元素之间的关联。sectionGroup:定义配置节处理程序与配置节之间的关联。-->
<configSections>
<sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
<sectionname="rewriter"type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter"/>
</configSections>
<!--appSettings是应用程序设置,可以定义应用程序的全局常量设置等信息。-->
<appSettings>
<addkey="ErrPage"value="http://www.cnblogs.com"/>
</appSettings>
<!--连接字符串设置-->
<connectionStrings>
<addname="sqlConnectionString"connectionString=""/>
</connectionStrings>
<!--指定应用子配置设置的资源,并锁定配置设置,以防止它们被子配置文件重写。path指定应用包含的配置设置的资源。allowOverride是否允许配置文件的重写,提高配置文件的安全性。-->
<locationpath="Default.aspx"allowOverride="false">
<!--控制asp.net运行时的行为-->
<system.web>
<!--identity控制web应用程序的身份验证标识.-->
<identityimpersonate="false" />
<!--标识特定于页的配置设置(如是否启用会话状态、视图状态,是否检测用户的输入等)。<pages>可以在计算机、站点、应用程序和子目录级别声明。
masterPageFile:默认主页为Index。
theme:主题是Default。
buffer:指定 URL 资源是否使用响应缓冲。默认值为 True。
enableViewStateMac:指定从客户端回发页时,ASP.NET 是否应该对页的视图状态运行消息身份验证代码 (MAC)。如果为 True,将检查加密的视图状态,以验证视图状态是否已在客户端被篡改。默认值为 True。
validateRequest:指示 ASP.NET 在从浏览器输入的所有内容中检查是否存在潜在的危险数据。如果是 True,则通过将所有输入数据与一个潜在危险值列表进行比较来执行请求验证。如果发生匹配,ASP.NET 将引发 HttpRequestValidationException 异常。默认值为 True。
enableViewState:指定视图状态是否启用并在多个页请求之间保持。默认值为 True。-->
<pagesmasterPageFile="Index"theme="Default"buffer="true"enableViewStateMac="true"validateRequest="false"enableViewState="false">
<!--controls 元素定义标记前缀所在的 register 指令和命名空间的集合-->
<controls></controls>
<!--将在程序集预编译期间使用的导入指令的集合-->
<namespaces></namespaces>
</pages>
<!--默认错误页设置。
mode:具有On,Off,RemoteOnly 3种状态。On表示始终显示自定义的信息; Off表示始终显示详细的asp.net错误信息; RemoteOnly表示只对不在本地Web服务器上运行的用户显示自定义信息。
defaultRedirect:用于出现错误时重定向的URL地址。-->
<customErrorsdefaultRedirect="Err.html"mode="RemoteOnly">
<!--特殊代码编号的错误从定向文件-->
<errorstatusCode="403"redirect="NoAccess.htm" />
<errorstatusCode="404"redirect="FileNotFound.htm" />
</customErrors>
<!--配置调试和跟踪。
enabled:是否为应用程序启用跟踪。默认值为 false。
localOnly:指定跟踪查看器 (Trace.axd) 是否只用于主机 Web 服务器。如果是 false,则跟踪查看器可用于任何计算机。默认情况下,Trace.axd 查看器被添加到 httpHandlers 元素。默认值为 true。
pageOutput:指定在每一页的结尾是否呈现跟踪输出。如果是 false,则只能通过跟踪实用工具访问跟踪输出。默认值为 false。
requestLimit:指定在服务器上存储的跟踪请求的数目。如果达到限制,并且 mostRecent 特性为 false,将自动禁用跟踪。最大请求限制为 10,000。如果指定了大于 10,000 的值,ASP.NET 会在不给出任何提示的情况下将它向下舍入到 10,000。默认值为 10。
traceMode:指定显示跟踪信息的顺序。traceMode 特性可以为下列可能值之一。
值 说明
SortByCategory 指定根据用户定义的类别按字母顺序显示跟踪信息。 SortByTime 指定以处理跟踪信息的顺序来显示跟踪信息。
默认值为 SortByTime。-->
<traceenabled="true"localOnly="false"pageOutput="true"requestLimit="15"traceMode="SortByCategory"/>
<!--设置 compilation debug="true" 将调试符号插入已编译的页面中。但由于这会影响性能,因此只在开发过程中将此值设置为 true。设置默认的开发语言C#。batch是否支持批处理-->
<compilationdebug="true"defaultLanguage="c#"batch="false">
<assemblies>
<!--加的程序集引用,每添加一个程序集,就表示你的应用程序已经依赖了一个程序集,你就可以在你的应用程序中使用了-->
<addassembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<addassembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addassembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<addassembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<addassembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<addassembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<addassembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
<!--定义用于编译自定义资源文件的生成提供程序的集合。-->
<buildProviders>
<addextension=".aspx"type="System.Web.Compilation.PageBuildProvider"/>
<addextension=".ascx"type="System.Web.Compilation.UserControlBuildProvider"/>
<addextension=".master"type="System.Web.Compilation.MasterPageBuildProvider"/>
<addextension=".asmx"type="System.Web.Compilation.WebServiceBuildProvider"/>
<addextension=".ashx"type="System.Web.Compilation.WebHandlerBuildProvider"/>
<addextension=".soap"type="System.Web.Compilation.WebServiceBuildProvider"/>
<addextension=".resx"type="System.Web.Compilation.ResXBuildProvider"/>
<addextension=".resources"type="System.Web.Compilation.ResourcesBuildProvider"/>
<addextension=".wsdl"type="System.Web.Compilation.WsdlBuildProvider"/>
<addextension=".xsd"type="System.Web.Compilation.XsdBuildProvider"/>
<addextension=".rdlc"type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.Common, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</buildProviders>
</compilation>
<!--通过 <authentication> 节可以配置 ASP.NET 使用的安全身份验证模式,以标识传入的用户。Windows: 使用IIS验证方式。Forms: 使用基于窗体的验证方式。Passport: 采用Passport cookie验证模式。None: 不采用任何验证方式。-->
<authenticationmode="Forms">
<!--Name: 指定完成身份验证的Http cookie的名称。
LoginUrl: 如果未通过验证或超时后重定向的页面URL,一般为登录页面,让用户重新登录。
Protection: 指定 cookie数据的保护方式。可设置为:All表示加密数据,并进行有效性验证两种方式,None表示不保护Cookie,Encryption表示对Cookie内容进行加密,validation表示对Cookie内容进行有效性验证。
TimeOut: 指定Cookie的失效时间。超时后要重新登录。-->
<formsname=".ASPXUSERDEMO"loginUrl="Login.aspx"protection="All"timeout="30"/>
</authentication>
<!--控制对 URL 资源的客户端访问(如允许匿名用户访问)。此元素可以在任何级别(计算机、站点、应用程序、子目录或页)上声明。必需与<authentication> 节配合使用。此处的意思是对匿名用户不进行身份验证。拒绝用户weipeng-->
<authorization>
<allowusers="*"/>
<denyusers="weipeng"/>
<allowusers="aa"roles="aa" />
</authorization>
<!--站点全球化设置,requestEncoding: 它用来检查每一个发来请求的编码。responseEncoding: 用于检查发回的响应内容编码.fileEncoding:用于检查aspx,asax等文件解析的默认编码,默认的编码是utf-8-->
<globalizationrequestEncoding="gb2312"responseEncoding="gb2312"fileEncoding="gb2312" />
<!--会话状态设置。
mode: 分为off,Inproc,StateServer,SqlServer几种状态。mode ="InProc" 存储在进程中,特点:具有最佳的性能,速度最快,但不能跨多台服务器存储共享。mode = "StateServer" 存储在状态服务器中特点:当需要跨服务器维护用户会话信息时,使用此方法。但是信息存储在状态服务器上,一旦状态服务器出现故障,信息将丢失。mode="SqlServer" 存储在sql server中特点:工作负载会变大,但信息不会丢失。
stateConnectionString:指定asp.net应用程序存储远程会话状态的服务器名,默认为本机。
sqlConnectionString:当用会话状态数据库时,在这里设置连接字符串。
Cookieless:设置为flase时,表示使用cookie会话状态来标识客户。
timeout:表示会话超时时间。-->
<sessionStatemode="InProc"stateConnectionString="tcpip=127.0.0.1:42424"sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"cookieless="false"timeout="20"></sessionState>
<!--为 ASP.NET 应用程序配置页的视图状态设置。设置要存储在页历史记录中的项数。-->
<sessionPageStatehistorySize="9"/>
<!--配置asp.net http运行库的设置。可以在计算机,站点,应用程序和子目录级别声明允许最多的请求个数100,最长允许执行请求时间为80秒,控制用户上传文件的大小,默认是4M。useFullyQualifiedRedirectUrl客户端重定向不需要被自动转换为完全限定格式。-->
<httpRuntimeappRequestQueueLimit="100"executionTimeout="80"maxRequestLength="40960"useFullyQualifiedRedirectUrl="false"/>
<!--httpModules在一个应用程序内配置 HTTP 模块。-->
<httpModules>
<addname="OutputCache"type="System.Web.Caching.OutputCacheModule" />
<addname="Session"type="System.Web.SessionState.SessionStateModule" />
<addname="WindowsAuthentication"type="System.Web.Security.WindowsAuthenticationModule"/>
<addname="FormsAuthentication"type="System.Web.Security.FormsAuthenticationModule" />
<addname="PassportAuthentication"type="System.Web.Security.PassportAuthenticationModule" />
<addname="RoleManager"type="System.Web.Security.RoleManagerModule" />
<addname="UrlAuthorization"type="System.Web.Security.UrlAuthorizationModule" />
<addname="FileAuthorization"type="System.Web.Security.FileAuthorizationModule" />
<addname="AnonymousIdentification"type="System.Web.Security.AnonymousIdentificationModule"/>
<!--自定义的URL重写,type基本上就是dll名-->
<addname="UrlRewriter"type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
<addname="Profile"type="System.Web.Profile.ProfileModule" />
</httpModules>
<!--httpHandlers用于根据用户请求的URL和HTTP谓词将用户的请求交给相应的处理程序。可以在配置级别的任何层次配置此节点,也就是说可以针对某个特定目录下指定的特殊文件进行特殊处理。
add:指定映射到处理程序的谓词/路径。
clear:移除当前已配置或已继承的所有处理程序映射。
remove:移除映射到处理程序的谓词/路径。remove 指令必须与前一个 add 指令的谓词/路径组合完全匹配。该指令不支持通配符。-->
<httpHandlers>
<removeverb="*"path="*.asmx"/>
<addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/>
<addverb="POST,GET"path="ajaxpro/*.ashx"type="AjaxPro.AjaxHandlerFactory, AjaxPro.2"/>
</httpHandlers>
<!--为 Web 应用程序使用的 Cookie 配置属性。
domain:设置 Cookie 域名。
httpOnlyCookies:在 Internet Explorer 6 SP1 中启用 HttpOnlyCookies Cookie 的输出。默认值为 false。
requireSSL:获取一个指示是否需要安全套接字层 (SSL) 通信的值.-->
<httpCookieshttpOnlyCookies="false"requireSSL="false"/>
<!--控制 ASP.NET Web 服务及其客户端的行为。
protocols:指定传输协议,ASP.NET 可使用这些传输协议来解密 HTTP-->
<webServices>
<protocols>
<add/>
</protocols>
</webServices>
<!--为 Web 应用程序配置缓存设置。
cache:定义全局应用程序缓存设置。
outputCache:指定应用程序范围的输出缓存设置。
outputCacheSettings:指定可以应用于应用程序中页的输出缓存设置。
sqlCacheDependency:为 ASP.NET 应用程序配置 SQL 缓存依赖项。-->
<caching>
<cachedisableMemoryCollection = "false"disableExpiration = "false"privateBytesLimit ="0"percentagePhysicalMemoryUsedLimit = "90"privateBytesPollTime = "00:02:00"/>
<!--设计需要以这种方式缓存的页时,您需要向该页添加以下指令:<%@ OutputCache CacheProfile="ServerOnly" %>-->
<outputCacheSettings>
<outputCacheProfiles>
<addname="ServerOnly"duration="60"varyByCustom="browser"location="Server" />
</outputCacheProfiles>
</outputCacheSettings>
</caching>
</system.web>
</location>
<!--网络设置。authenticationModules:指定用于对 Internet 请求进行身份验证的模块。connectionManagement:指定与 Internet 宿主的连接的最大数目。defaultProxy:配置超文本传输协议 (HTTP) 代理服务器。mailSettings:配置简单邮件传输协议 (SMTP) 邮件发送选项。requestCaching:控制网络请求的缓存机制。settings:配置 System.Net 的基本网络选项。-->
<system.net>
<!--配置SMTP电子邮件设置-->
<mailSettings>
<smtpfrom="sy">
<networkhost="Gao"password=""userName="" />
</smtp>
</mailSettings>
<!--禁用所有缓存-->
<requestCachingdisableAllCaching="true"></requestCaching>
<!--指定代理地址,并对本地访问和 contoso.com 跳过代理。-->
<defaultProxy>
<proxyusesystemdefault="True"proxyaddress="http://192.168.1.10:3128"bypassonlocal="True"/>
<bypasslist>
<addaddress="" />
</bypasslist>
</defaultProxy>
</system.net>
<!--该节替换在 httpHandlers 和 httpModules 节中添加的与 AJAX 相关的 HTTP 处理程序和模块。该节使 IIS 7.0 在集成模式下运行时可使用这些处理程序和模块。在iis7.0 下运行 ASP.NET AJAX 需要 system.webServer节。对早期版本的 IIS 来说则不需要此节。 -->
<system.webServer>
<validationvalidateIntegratedModeConfiguration="false"/>
<modules>
<addname="ScriptModule"preCondition="integratedMode"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
<removename="WebServiceHandlerFactory-Integrated"/>
<addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>
</system.webServer>
<!--ASP.NET AJAX 中配置 ASP.NET 服务-->
<system.web.extensions>
<!--配置 JSON 序列化-->
<scripting>
<webServices>
<jsonSerializationmaxJsonLength="5000"/>
</webServices>
</scripting>
</system.web.extensions>
<!--对WCF的相关配置-->
<system.serviceModel>
<services>
<servicename="WCFStudent.WCFStudentText"behaviorConfiguration="ServiceBehavior">
<!-- Service Endpoints -->
<endpointaddress=""binding="wsHttpBinding"contract="WCFStudent.IStuServiceContract">
<!--部署时,应删除或替换下列标识元素,以反映在其下运行部署服务的标识。删除之后,WCF 将自动推导相应标识。-->
<identity>
<dnsvalue="localhost"/>
</identity>
</endpoint>
<endpointaddress="mex"binding="mexHttpBinding"contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behaviorname="ServiceBehavior">
<!--为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
<serviceMetadatahttpGetEnabled="true"/>
<!--要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
<serviceDebugincludeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<!--URL重定向-->
<rewriter>
<rewriteurl="~/user/u(.+).aspx"to="~/user/index.aspx?r=$1" />
<rewriteurl="~/ask/q(.+).aspx"to="~/home/ask/content.aspx?id=$1" />
<rewriteurl="~/blog/b(.+).aspx"to="~/home/blog/article.aspx?r=$1" />
<rewriteurl="~/news/n(.+).aspx"to="~/home/news/content.aspx?nid=$1" />
<rewriteurl="~/default.aspx"to="~/home/ram/net.aspx" />
</rewriter>
</configuration>