文章詳情頁
asp.net web api2設置默認啟動登錄頁面的方法
瀏覽:49日期:2022-06-08 18:07:33
1.在Global.asax文件中添加Application_BeginRequest方法,如下如所示:
public class WebApiApplication : HttpApplication{ protected void Application_Start() {log4net.Config.XmlConfigurator.Configure(new FileInfo(Server.MapPath("~/Web.config")));AreaRegistration.RegisterAllAreas();GlobalConfiguration.Configure(WebApiConfig.Register);FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);RouteConfig.RegisterRoutes(RouteTable.Routes);BundleConfig.RegisterBundles(BundleTable.Bundles); } protected void Application_BeginRequest(object sender, EventArgs e) {if (Context.Request.FilePath == "/") Context.RewritePath("home/page/login.html"); }}
靜態頁面的目錄結構如下所示:
2.等啟動項目后,到了登錄頁,有可能會發現靜態資源,如圖片,css,js文件全部加載失敗,這個時候需要修改一下路徑,如下所示:
登錄成功跳轉的頁面也要注意下。
備注:項目使用rider2022.2.3開發
到此這篇關于asp.net web api2設置默認啟動登錄頁面的文章就介紹到這了,更多相關asp.net web api2默認登錄頁面內容請搜索以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持!
標簽:
ASP.NET
排行榜