ASPnet_client位置自定义

有人发帖问“ASPnet_client必须放在Web根目录吗?怎样改变这个路径?”

  我一开始猜想这个路径可能是硬编码的。为了证实一下,就打开了Reflector,试图寻找到类似"/aspnet_client/system_web/1_1_4322/"的字符串,却发现这个目录的位置是可以自定义的,但是MSDN中没有公开。相关代码在System.Web.UI.Util.GetScriptLocation(HttpContext)中,

  1internal static string GetScriptLocation(HttpContext context)
  2...{
  3 string text1 = null;
  4 IDictionary dictionary1 = (IDictionary) context.GetConfig("system.web/webControls");
  5 if (dictionary1 != null)
  6 ...{
  7 text1 = (string) dictionary1["clientScriptsLocation"];
  8 }
  9 if (text1 == null)
  10 ...{
  11 throw new HttpException(HttpRuntime.FormatResourceString("Missing_clientScriptsLocation"));
  12 }
  13 if (text1.IndexOf("{0}") >= 0)
  14 ...{
  15 string text2 = "system_web";
  16 string text3 = VersionInfo.ISAPiVersion.Substring(0, VersionInfo.IsapiVersion.LastIndexOf('.')).Replace('.', '_');
  17 text1 = string.Format(text1, text2, text3);
  18 }
  19 return text1;
  20}

    然后再machine.config中找到了默认的配置:

<webControls clientScriptsLocation="/aspnet_client/{0}/{1}/" />

  当然也可以在web.config中针对单个应用程序进行配置。如果要把aspnet_client目录放在根目录下的myweb中,那么就在web.config文件的

  <configuration>
   <system.web>

  标签内加上这么一句:

   <webControls clientScriptsLocation="/myweb/aspnet_client/{0}/{1}/" />

  或者直接写

   <webControls clientScriptsLocation="/myweb/aspnet_client/system_web/1_1_4322/" />

  就可以了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值