Я только что нашел an article на CodeProject, что заставило меня очень интересно ... Так что я реализовал этот здесь:WebResource.axd дает 404
У меня есть два проекта:
- MyComponent.Web (удерживая все ресурсы и средства управления)
- MyComponent.Web.Demo (только WebProject)
в MyComponent.Web У меня есть
AssemblyInfo.cs
[assembly: WebResource(WebResourceHelper.JQueryPath, "text/javascript")]
WebResourceHelper.cs
public static class WebResourceHelper
{
internal const string JQueryPath = "MyComponent.Web.WebResources.jQuery.jquery-1.5.1.min.js";
public static void RegisterJQuery(this Page page)
{
page.RegisterWebResource(JQueryPath);
}
public static void RegisterWebResource(this Page page, string path)
{
Contract.Requires(page != null);
Contract.Requires(!string.IsNullOrEmpty(path));
var pageType = page.GetType();
var webResourcePath = page.ClientScript.GetWebResourceUrl(pageType, path);
page.ClientScript.RegisterClientScriptResource(pageType, webResourcePath);
}
}
TextBox.cs
// namespace: MyComponent.Web.UI.WebControls
public sealed class TextBox : System.Web.UI.WebControls.TextBox
{
#region life cycle
protected override void OnInit(System.EventArgs e)
{
base.OnInit(e);
this.Page.RegisterJQuery();
}
#endregion
}
и, кроме того мой скрипт-файл с набором сборки действий по Embedded Resource
В MyComponent.Web.Demo
У меня есть
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<myComponent:TextBox runat="server" ID="textBox" />
</div>
</form>
</body>
</html>
web.config
<system.web>
<pages>
<controls>
<add tagPrefix="myComponent" namespace="MyComponent.Web.UI.WebControls" assembly="MyComponent.Web" />
</controls>
</pages>
</system.web>
Но WebResource.axd
дает мне 40 4, тогда как Reflector показывает мне, что я правильно вложил ресурс - так что я делаю неправильно здесь?
Edit Вы можете скачать a demo here
Вопрос такой же? http://stackoverflow.com/questions/435311/asp-net-webresource-axd-call-404-error-how-to-know-which-assembly-resource-is-m – Shoban
@Shoban: нет ... Инструмент telerik дает мне 'pApp_Web_7jmvne45 | MyComponent.Web.WebResources.jQuery.jquery-1.5.1.min.js', который выглядит правильно для меня ... примечательный: dropDown' Выберите веб-ресурс на этой странице: 'telerik Инструмент не имеет элементов ... –