0
我在網站panle上傳我的網站後出現此錯誤 無法找到資源。使用global.asax時找不到資源
說明:HTTP 404。您正在尋找(或它的 的一個依賴項)可能已被刪除的資源,有其名稱更改,或者是 暫時不可用。請檢查以下URL並確定 拼寫正確。
請求的URL:/.aspx
,因爲當我從主機中刪除我的網站運行currectly 我的Global.asax代碼,我認爲它於Global.asax中相關
namespace officeWeb
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
protected void Session_Start(object sender, EventArgs e)
{
}
protected void Application_BeginRequest(object sender, EventArgs e)
{
String fullOrigionalpath = Request.Url.ToString();
String[] sElements = fullOrigionalpath.Split('/');
String[] sFilePath = sElements[sElements.Length - 1].Split('.');
if (!fullOrigionalpath.Contains("__browserLink"))
{
//Rewrite
if (!fullOrigionalpath.Contains(".aspx") && sFilePath.Length == 1)
{
Context.RewritePath(sFilePath[0] + ".aspx");
}
}
}
protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
}
protected void Application_Error(object sender, EventArgs e)
{
}
protected void Session_End(object sender, EventArgs e)
{
}
protected void Application_End(object sender, EventArgs e)
{
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.Add("",
new Route("root/pages/service/{*pathInfo}", new WebServiceRouteHandler("~/root/config/services.asmx")));
}
public class WebServiceRouteHandler : IRouteHandler
{
private static IHttpHandlerFactory ScriptHandlerFactory;
static WebServiceRouteHandler()
{
var assembly = typeof(System.Web.Script.Services.ScriptMethodAttribute).Assembly;
var type = assembly.GetType("System.Web.Script.Services.ScriptHandlerFactory");
ScriptHandlerFactory = (IHttpHandlerFactory)Activator.CreateInstance(type, true);
}
private string virtualPath;
public WebServiceRouteHandler(string virtualPath)
{
this.virtualPath = virtualPath;
}
public IHttpHandler GetHttpHandler(RequestContext requestContext)
{
string pathInfo = requestContext.RouteData.Values["pathInfo"] as
if (!string.IsNullOrWhiteSpace(pathInfo))
pathInfo = string.Format("/{0}", pathInfo);
requestContext.HttpContext.RewritePath(this.virtualPath, pathInfo, requestContext.HttpContext.Request.QueryString.ToString());
var handler = ScriptHandlerFactory.GetHandler(HttpContext.Current, requestContext.HttpContext.Request.HttpMethod, this.virtualPath, requestContext.HttpContext.Server.MapPath(this.virtualPath));
return handler;
}
}
}
}
什麼我應該怎麼做? 請幫助我
感謝您的關注,但是當我在global.asax中刪除我的代碼時,在根中放入了空gloabl.asax我得到同樣的錯誤,在本地主機中它的工作正確 –
我很困惑。它沒有global.asax工作,還是不工作沒有?在你的問題中,你說它沒有工作,現在你說它沒有工作。 – Nzall
當我從主機中刪除它的工作,並且當我添加這個主機它是劑量工作(我本地主機它的工作) –