本人初次接觸ASP.NET MVC,想請教各位大神一個問題,Global.asax檔案代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
namespace WebApplication3
{
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
}
本人有兩個地方不太明白:
(1)BundleConfig和RouteConfig檔案位于App_Start檔案夾下,為什么全域檔案不需要添加相應檔案夾的命名空間就能直接使用BundleConfig和RouteConfig檔案。
(2)我也試過新建一個MVC空專案,然后自己寫BundleConfig檔案,最后發現全域檔案中無法直接使用BundleConfig和RouteConfig,需要添加using WebApplication1.App_Start才能使用。
還請各位大神能夠指點一下哈。
uj5u.com熱心網友回復:
命名空間你隨意, 不是說在App_Start檔案夾下 就一定要 App_Start 命名空間, 你新建的專案 App_Start 檔案夾下的config 都是專案名稱的命名空間 不帶 App_Start , 是和 Global檔案里的類 相同的命名空間, 當然能直接用了,轉載請註明出處,本文鏈接:https://www.uj5u.com/net/123699.html
標籤:ASP.NET
下一篇:未能決議目標框架“.NETFramework,Version=v4.6”的 mscorlib。如果未安裝目標框架或框架名字物件的格式不正確,
