ASP.NET:WebResource.axd调用404错误:如何知道哪个程序集/资源丢失或负责?
| 
                         我在ASP.NET 3.5(AJAX)Web应用程序中的特定WebResource.axd调用上收到404 HTTP状态错误(未找到)。我猜错误被抛出,因为在bin文件夹/ GAC中缺少一个特定的被引用的程序集。但我不知道哪个,因为请求资源的页面是非常复杂的(我使用第三方控件和ASP.NET Ajax。) 是否可以从查询的加密的“d”querystring参数知道,如: .../WebResource.axd?d=... 哪个程序集应该创建内容并可能丢失? 注意:还有其他WebRequest.axd调用成功执行。 解决方法此问题的原因之一是注册的嵌入式资源路径不正确或资源不存在。确保资源文件添加为 Embedded Resource。Asp.net使用WebResourceAttribute,它必须给出资源的路径。 资源文件需要作为嵌入式资源添加到项目,并且它的路径将是完整的命名空间加上文件名。 因此,在项目“MyAssembly”中有以下项目资源“my.js”,资源路径将是“MyAssembly.my.js”。 要检查Web资源处理程序找不到什么文件,您可以解密WebResource.axd URL上提供的哈希码。请看下面的例子一个怎么做。 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(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,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?";
            } 
        }
    }
} 
 原始代码示例由Telerik UI为ASP.NET AJAX Team Link: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路径。 (编辑:莱芜站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!  | 
                  
- asp.net-web-api – WebApi 2.1 PUT抛出错误415
 - 如何在ASP.NET Web应用程序中打开一个SectionGroup?
 - 61条面向对象设计的经验原则 转载
 - asp.net – GetExternalLoginInfoAsync()loginInfo返回null
 - asp.net-mvc – 如何正确识别vs2008版本级别?
 - asp.net-mvc – ASP.net身份在删除外部帐户后停止分发外部C
 - asp.net – Request.Browser.Platform不返回iPad,OSX或Wind
 - asp.net-mvc – 防止在ASP.NET MVC中缓存属性,每次执行一个
 - ASP.NET:将内容注入所有Response流
 - asp.net-mvc-3 – 如何关闭我的整个ASP.NET MVC 3网站的缓存
 
- asp.net-mvc-3 – 在MVC3中使用Html.LabelFor的表
 - 选择顶部N值,但跳过M个结果
 - asp.net – 何时覆盖OnError?
 - asp.net – 为什么Global.asax事件在我的ASP.NET
 - asp.net 禁用viewstate在web.config里
 - asp.net – Combres的路线(combres.axd)不起作用
 - Asp.net webForm设置允许表单提交Html的方法
 - asp.net-mvc – ASP.NET MVC – Partial View可以
 - 解决asp.net Sharepoint无法连接发布自定义字符串
 - asp.net-mvc – 如何在RegularExpression中忽略大
 
