$ where paramを検索して変更し(DateTime.NowをDateTime.UtcNowに置き換え)、パスを書き換えるカスタムHttpModuleを作成しました。簡略化されたモジュールの実装は次のようになります。
private void OnBeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
string whereQuery = app.Request.QueryString["$where"];
string newWhereQuery = this.ChangeWhereQuery(whereQuery);
// Combine new where query string with other query strings
string newQueryString = this.BuildQueryString(app, newWhereQuery);
app.Context.RewritePath(app.Request.FilePath, app.Request.PathInfo, newQueryString);
}
問題は、クエリ式を書き換えた後、つまりDomainServiceのQueryメソッドqueryDescription.Queryがnullになることです。
public override IEnumerable Query(QueryDescription queryDescription, out IEnumerable<ValidationResult> validationErrors, out int totalCount)
{
// queryDescription.Query is null
return base.Query(queryDescription, out validationErrors, out totalCount);
}
カスタムモジュールを次のコードに置き換えると(パスは元のクエリ文字列で書き直されます)、すべてが正常に機能します。
private void OnBeginRequest(object sender, EventArgs e)
{
HttpApplication app = sender as HttpApplication;
string qs = app.Request.QueryString.ToString();
app.Context.RewritePath(app.Request.FilePath, app.Request.PathInfo, qs);
}
この投稿をSilverlightフォーラムで見つけましたが、スレッドURLはもう利用できません。
WCF RIAサービス自体はURL書き換えを使用するため、競合が発生する可能性があります。解決策のある最近のスレッドは次のとおりです:http: //forums.silverlight.net/forums/p/233310/573340.aspx#573340
URLクエリ文字列を変更した後にクエリ式が失われる理由は何ですか?
WCF RIA Services V1.0 SP2、.NET 4、およびIIS7を使用しています。