取得web.config中設定之location

取得web.config中設定之location

前陣子因為網站的Session控管,所以我在Global.asax中會去判斷目前網址及Session是否還

存在,若是不存在就要導回首頁。可是有部份網頁是不需要經過驗證登入就必須要可以

瀏覽,例如:測試頁。

 

原本是利用web.config中去設定location,可是因為在Global.asax中又重新導頁的關係,導

至設定的location完全失效,因此需要重新判斷location到底設定了哪些不需要判斷Session

是否還存在。

 

取得location的方式是利用WebConfigurationManager,就可以看得到屬性了。

 

image

 


string appPath =  ctx.Request.ApplicationPath;

Configuration config = WebConfigurationManager.OpenWebConfiguration(appPath);

for (int i = 0; i < config.Locations.Count; i++)
{
	if (path.IndexOf(config.Locations[i].Path) > 0)
		check = false;

}

 

DotBlog 的標籤:,