none
asp.net query string parameter RRS feed

  • Question

  • I am new in ASP.net

    I see some website using query parameter for example (http://hostname/path.aspx?name=a&phone=45)

    I understand this parameter. but I dont understand (http://hostname/path.jpg?a=x&b=y or http://hostname/path.cssx?a=x etc)

    how can I use query parameter in jpg, cssx, jssx, or another extension file in ASP.Net


    KishanMundha

    Saturday, March 31, 2012 5:57 AM

Answers

  • [...] I dont understand (http://hostname/path.jpg?a=x&b=y or http://hostname/path.cssx?a=x etc)

    how can I use query parameter in jpg, cssx, jssx, or another extension file in ASP.Net

    The "standard" mechanisms that you usually employ in asp.net will not let you execute code when it is serving a jpg or other "non-active-page" piece of data, and therefore there is no opportunity for you to process those parameters. However, you could trick the engine into running your code instead of having the conventional behavior when such a request is received. One way to do it is to add an HttpModule and perform some URL rewriting. Take a look at this article:

    http://msdn.microsoft.com/en-us/library/ms972974.aspx

    But anyway, this is not something that you want to discuss in the Training and Certification Forum. As a previous message already suggested, a good place to talk about this subject would be the asp.net forums:

    http://forums.asp.net/

    Saturday, March 31, 2012 11:34 AM

All replies

  • Hello,

    Post this question of "Forums.asp.net" for better response.

    Saturday, March 31, 2012 9:14 AM
  • [...] I dont understand (http://hostname/path.jpg?a=x&b=y or http://hostname/path.cssx?a=x etc)

    how can I use query parameter in jpg, cssx, jssx, or another extension file in ASP.Net

    The "standard" mechanisms that you usually employ in asp.net will not let you execute code when it is serving a jpg or other "non-active-page" piece of data, and therefore there is no opportunity for you to process those parameters. However, you could trick the engine into running your code instead of having the conventional behavior when such a request is received. One way to do it is to add an HttpModule and perform some URL rewriting. Take a look at this article:

    http://msdn.microsoft.com/en-us/library/ms972974.aspx

    But anyway, this is not something that you want to discuss in the Training and Certification Forum. As a previous message already suggested, a good place to talk about this subject would be the asp.net forums:

    http://forums.asp.net/

    Saturday, March 31, 2012 11:34 AM
  • Hi Kishan,

    Alberto has provided you with an answer and because I can't move your question to http://forums.asp.net/, I have marked his reply as the answer.  You should however post a follow-up question in the http://forums.asp.net/ forum. 


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID: Microsoft Transcript

    Sunday, April 1, 2012 1:13 AM
    Moderator