ASP.NET:WebResource.axd的调用404错误:如何知道哪个程序集/资源已丢失或负责任? [英] ASP.NET: WebResource.axd call 404 error: how to know which assembly/resource is missing or responsible?

查看:137
本文介绍了ASP.NET:WebResource.axd的调用404错误:如何知道哪个程序集/资源已丢失或负责任?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了 404 HTTP状态错误(未找到)上的特定WebResource.axd的的ASP.NET 3.5(AJAX)的Web应用程序中调用。我猜引发错误,因为一个特定的引用的程序集在bin文件夹/ GAC失踪。但我不知道是哪个,因为它要求的资源页面很复杂(我使用第三方控件和ASP.NET AJAX)。

I get a 404 HTTP status error (not found) on a specific WebResource.axd call inside an ASP.NET 3.5 (AJAX) web application. I guess the error is thrown because a specific referenced assembly is missing in the bin folder/GAC. But I don't know which, since the page which requests the resource is very complex (I'm using third-party controls and ASP.NET Ajax.)

是否有可能从加密的D知道查询字符串的查询参数,如:

Is it possible to know from the encrypted "d" querystring parameter of the query, like:

.../WebResource.axd?d=...

这件应创建内容,并可能丢失?

which assembly should create the content and is possibly missing?

注意:有哪些成功执行其它WebRequest.axd电话

Note: There are other WebRequest.axd calls which execute with success.

推荐答案

其中的一个原因这个问题,被注册的嵌入资源路径不正确或资源是不存在。确保资源文件添加为嵌入的资源

One of the reasons for this issue is that the registered embedded resource path is incorrect or the resource is not there. Make sure the resource file is added as a Embedded Resource.

Asp.net使用 WebResourceAttribute 你必须给路径的资源。

Asp.net uses the WebResourceAttribute which you must give the path to the resource.

资源文件需要被添加为嵌入的资源,以项目和路径,这将是完整的命名空间加上文件名。

The resource file needs to be added as a Embedded Resource to the project and the path to it would be the full namespace plus the file name.

所以,你必须在项目中的以下项目资源my.jsMyAssembly程序资源路径将是MyAssembly.my.js。

So you have the following project resource "my.js" in the project "MyAssembly" the resource path would be "MyAssembly.my.js".

要检查哪些文件是网络资源的处理程序没有找到您可以解密提供的网址WebResource.axd的哈希code。请看下面的例子是如何做到这一点。

To check what file the web resource handler is not finding you can decrypt the hash code provided on the WebResource.axd url. Please see the example below an how to do that.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            byte[] encryptedData = HttpServerUtility.UrlTokenDecode("encoded hash value");

            Type machineKeySection = typeof(System.Web.Configuration.MachineKeySection);
            Type[] paramTypes = new Type[] { typeof(bool), typeof(byte[]), typeof(byte[]), typeof(int), typeof(int) };
            MethodInfo encryptOrDecryptData = machineKeySection.GetMethod("EncryptOrDecryptData", BindingFlags.Static | BindingFlags.NonPublic, null, paramTypes, null);

            try
            {
                byte[] decryptedData = (byte[])encryptOrDecryptData.Invoke(null, new object[] { false, encryptedData, null, 0, encryptedData.Length });
                string decrypted = System.Text.Encoding.UTF8.GetString(decryptedData);

                decryptedLabel.Text = decrypted;
            }
            catch (TargetInvocationException)
            {
                decryptedLabel.Text = "Error decrypting data. Are you running your page on the same server and inside the same application as the web resource URL that was generated?";
            } 
        }
    }
}

原始code例如通过Telerik的UI为ASP.NET AJAX Team链接:<一个href=\"http://blogs.telerik.com/aspnet-ajax/posts/07-03-27/debugging-asp-net-2-0-web-resources-decrypting-the-url-and-getting-the-resource-name.aspx\" rel=\"nofollow\">http://blogs.telerik.com/aspnet-ajax/posts/07-03-27/debugging-asp-net-2-0-web-resources-decrypting-the-url-and-getting-the-resource-name.aspx

这应该返回aspt.net认为嵌入的资源是URL路径。

This should return the URL path that aspt.net believes the embedded resource is at.

这篇关于ASP.NET:WebResource.axd的调用404错误:如何知道哪个程序集/资源已丢失或负责任?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆