asp.net mvc - UrlRewrite not working when using TransferRequest -


i have urlrewrite rule, looks this:

<rewrite>     <rules>                      <rule name="add prefix pictures request" stopprocessing="true">           <match url="^pictures/(.*)" />           <action type="rewrite" url="/pictures/pictures-dev/{r:1}" appendquerystring="true" logrewrittenurl="true" />         </rule>     </rules> </rewrite> 

the idea add kind of prefix original request (in case, prefix /pictures/pictures-dev/. later rewritten request processed plugin , not handled code. /pictures endpoint main endpoint such requests. rewrite rule vital, , without rule applied request won't processed.

also have controller named imagescontroller, has single method get. method should act /pictures endpoint, additional processing. thing important /images endpoint cannot issue client-side redirect (http 301) design.

so, desired redirect requests /images /pictures. due additional processing, cannot redirect requests /images /pictures.

to achieve this, i've done following in imagescontroller:

[system.web.http.httpget] public ihttpactionresult get(long id) {      // work done here      // ....      // transferrequest not return in case of successful request      httpcontext.current.server.transferrequest($"~/pictures/{id}", true);       return null;  } 

as i've found lot transferrequest, method should re-run whole iis request stack, suppose urlrewrite should executed.

i expect "pictures/{id}" rewritten "/pictures/pictures-dev/{id}". however, see "/pictures/{id}" issued transferrequest not rewritten, makes me think urlrewrite module not executed against "transferred" request.

what missing? or maybe there other ways achieve this?

thanks!


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -