spl*_*tne 24 asp.net assemblies webresource.axd
我在ASP.NET 3.5(AJAX)Web应用程序内的特定WebResource.axd调用上收到404 HTTP状态错误(未找到).我猜错误是因为bin文件夹/ GAC中缺少特定的引用程序集.但我不知道哪个,因为请求资源的页面非常复杂(我正在使用第三方控件和ASP.NET Ajax.)
是否可以从查询的加密"d"查询字符串参数中获知,如:
.../WebResource.axd?d=...
Run Code Online (Sandbox Code Playgroud)
哪个程序集应该创建内容并且可能丢失?
注意:还有其他WebRequest.axd调用成功执行.
Dia*_*tis 32
此问题的原因之一是注册的嵌入式资源路径不正确或资源不存在.确保将资源文件添加为嵌入式资源.
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(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?";
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
Telerik UI for ASP.NET AJAX Team Link的原始代码示例:http://blogs.telerik.com/aspnet-ajax/posts/07-03-27/debugging-asp-net-2-0-web-resources-解密最网址和得到最资源name.aspx
这应该返回aspt.net认为嵌入式资源所在的URL路径.
Koe*_*ers 11
我花了好几个小时才处理类似问题.由于Diadistis指出的伟大文章,我能够解密WebResource网址并发现我的WebResource被翻译成错误的程序集指针,可以通过资源名称前面的垃圾识别.经过多次努力,我发现这是因为我在一个类中使用了Page.ClientScript.GetWebResourceUrl,该类派生自另一个类,它位于我的资源所在的程序集之外.令人困惑的是,我的类在同一个程序集中是WAS,尽管源自的类是NOT.this.GetType()参数很多文章状态是必须的,事实证明在我的情况下根本不是必须的.实际上,它需要替换为typeof()并且它有效!希望这可以防止其他人像我从这个bugger那样得到同样的头痛.
| 归档时间: |
|
| 查看次数: |
26562 次 |
| 最近记录: |