QueryString["path"]
main.css などの独自の css ファイルに対して、すべてのものから縮小および圧縮するための css ファイルを取得しています。しかし、webresource ファイルにアクセスしようとすると、500 エラーが発生します。webresource.axd の後に続くパラメーターは大文字と小文字が区別され、QueryString["path"]
小文字から受け取ります。
これは私が得るものですQueryString["path"]
:
http://localhost/test/webresource.axd?d=-phgrn6r6zgehvbi697-bxvkl_gidnplxpdeukz5kncgr9hvnfvttpgykwyw05cda-nymtz9od_bbww3ynzxha2&t=633789305460522066
上記のリンクはエラーを生成します: CryptographicException: パディングが無効であり、削除できません。
正しいリンクは次のようになります。
http://localhost/test/WebResource.axd?d=-pHGRn6r6ZGehvBI697-BxVKl_GIdNPlxPdEUKZ5KNcGR9hvnfVtTpgyKwYw05cDa-NymTz9OD_bBwW3ynZXhA2&t=633789305460522066
唯一の違いはケースにあります。CryptographicException は一般的なようですが、machineKey を設定しても問題は解決しませんでした。元のケースで webresource.axd を取得する方法についてのヒントはありますか?
編集
コードが要求されました:
public void ProcessRequest(HttpContext context) {
Control c = new Control();
string root = context.Request.Url.GetLeftPart(UriPartial.Authority);
string path = context.Request.QueryString["path"];
string content = string.Empty;
if (!string.IsNullOrEmpty(path)) {
if (context.Cache[path] == null) {
List<string> dependencies = new List<string>();
string[] styles = path.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
foreach (string style in styles) {
content += RetrieveStyle(root + c.ResolveUrl(style)) + Environment.NewLine;
dependencies.Add(context.Server.MapPath(style));
}
content = StripWhitespace(content);
context.Cache.Insert(path, content, new CacheDependency(dependencies.ToArray()), Cache.NoAbsoluteExpiration, new TimeSpan(DAYS_IN_CACHE, 0, 0, 0));
}
}
}
を呼び出すと、RetreiveStyle でクラッシュします。
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())