我在网站panle上传我的网站后,我收到此错误 无法找到资源。
描述:HTTP 404.您正在寻找的资源(或其中一个 依赖项)可能已被删除,其名称已更改,或者是 暂时不可用。请查看以下网址并制作 确保它拼写正确。
请求的网址:/.aspx
我认为它与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;
}
}
}
}
我该怎么办? 请帮帮我
答案 0 :(得分:0)
如果您查看请求的网址,则会显示/.aspx
。这是一个无效的URL,因为它错过了实际的文件名,只有扩展名。
您需要调试代码并查看Application_BeginRequest()
中的变量值是否符合您的预期。可能他们不是。