【发布时间】:2013-05-30 02:44:47
【问题描述】:
我在我的一个站点中使用 UrlRewriting 模块,该站点有 2 个版本:
- 桌面
- 手机
网站的移动版代码仅存在于桌面版中,即如果桌面版位于c:\websites\[websitename],则移动版网站将为c:\websites\[websitename]\mobile
现在我有一个从 UI 到 add/modify/delete 和 vanity url's 的实用程序,所以对于 vanity url's,我创建了一个名为 url.config 的单独文件并将其链接到 rewrite 节点下的 web.config 文件.每当添加任何新的虚荣心时,我都会更新数据库,然后从数据库中更新整个 url.config 文件并刷新 web.config。
Web.config 刷新已经完成
Public Sub RefreshWebConfig()
Dim doc As New XmlDocument()
doc.Load(HttpContext.Current.Server.MapPath("web.config"))
doc.Save(HttpContext.Current.Server.MapPath("web.config"))
End Sub
上面的代码按预期工作,它刷新了web.config 文件,因此添加的虚荣当场生效。
现在我的客户要求将桌面版添加的梳妆台同时更新到移动版。所以现在我正在做的是我在mobile\urls.config 下创建了一个单独的文件,并链接到mobile\ web.config 文件,与桌面版本相同。
现在我正在使用下面的代码来刷新 mobile\web.config 文件,如下所示:
Public Sub RefreshWebConfig()
Dim doc As New XmlDocument()
doc.Load(HttpContext.Current.Server.MapPath("web.config"))
doc.Save(HttpContext.Current.Server.MapPath("web.config"))
Dim doc1 As New XmlDocument()
doc1.Load(HttpContext.Current.Server.MapPath("~/mobile/web.config"))
doc1.Save(HttpContext.Current.Server.MapPath("~/mobile/web.config"))
End Sub
但是,它不会使用上面的代码刷新mobile\web.config 文件,因为我需要等待5-10mins 左右或有时甚至直到20mins 才能使更改反映在移动站点上。
谁能告诉我是什么导致了这个问题,以及可能的解决方法。
【问题讨论】:
标签: asp.net url-rewriting web-config refresh