.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Set Querystring without Page.Request.Path

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net

I do now have the following code for the postback of my dropdownlist.

Response.Redirect(Page.Request.Path.ToString() + "?id=" + (Convert.ToDateTime(ddlDatum.SelectedValue)).ToString("yyyyMMdd"));

Is there another way to do this with the ddlDatum.SelectedValue remembered?

View Complete Post

More Related Resource Links

How to find incoming url of the page. ( alternative to Request.UrlReferrer)


 Request.UrlReferrer is not working. can any one  help me to find the previous page url ?

question regarding request.querystring


I have a url like this:

http://www.somepage.com/main.aspx.  In this page, when I click on a link it takes me to a page http://www.somepage.com/cental.aspx?cid=200.  So in the cental.aspx.cs page I did the following in the page load:


if(request.querystring["comp"].tostring() != null)


//do some thing


So I got an error like: object reference not set to an instance of reference.


My problem is, I am using the same page.  So when I go from some page, I will have "comp".  but other times not.  So when there is no "comp", how do I handle it in request.querystring?


Request.Querystring and UrlDecoding


(asp.net 2.0, c#)


I have a page requesting a qyerystring looking like this ?test=b%E4st, %E4 is the url-encoded letter ä. I can't change how this looks and encodes since I have no access to the page doing the request.

string strTest = Request.Querystring["test"].ToString();

If I then, for instance, just Response.Write(strTest) the character ä (%E4) is broken. Displayed as a question mark. I have in my web.config the requestEncoding and responseEncoding set to utf-8. That is the way I need to have it, and I can't change that.

I've looked around for a solutions for this and the issue seems to be iso-8859-1 vs utf-8 in the querystring and url-decoding. It seems the Request.Querystring automatically url-decodes the string using the default encoding, in my case utf-8. I need it to url-decode using iso-8859-1 instead. I can achieve this by altering the web.config, but as I said earlier this is not an option.

I have tried to do this:

Encoding enc = Encoding.GetEncoding(28591);
string strTest= Request.QueryString["test"];
strTest= HttpUtility.UrlDecode(strTest, enc);

Not working, since the Request.QueryString already has url-decoded the value using utf-8.

Can I somehow override the requestEncoding in the web.config? Or is the any other way of doing this?

HyperLink use to send request parameter to another page


The statement is correct:

<asp:HyperLink ID="HyperLink2" runat="server" Text

Request.PathInfo losing Master Page content and CSS link


Hi All-


I'm using Request.PathInfo to response.redirect as user to a different page ( based on the content after .aspx ).  It redirect just fine however, once redirected, the page loses all content from the master page and the CSS link.  I've searched and can't find an answer. 

Does anyone have a solution for this?

How is the Path property set in Request.Path?

I have a website which is running on a locally on IIS, and have noticed that I can display an image in /Image/MyImage.jpg from an aspx file in the web root directory with either of the following html:<img src="Image/MyImage.jpg...> or <img src="../Image/MyImage.jpg...>Even though these point to different locations, and <img src="../Image/MyImage.jpg...> is incorrect, they both work and the image is displayed correctly.I've looked into this, and in Application_BeginRequest(), HttpApplication.Context.Current.Request.Path is "/Image/MyImage.jpg" in both cases, which is correct.If I run the website on the local ASP.NET development environment (localhost), it never calls Application_BeginRequest() for the image, and only <img src="Image/MyImage.jpg...> works, which is what I would expect.How is the Request.Path variable set? I find it confusing that two different resource locations would cause the path in Request.Path to point to the same location.

How to link Title to it's associated page in list view without URL path column visible -bug?

I don't know if this is a bug or if I'm an idiot (or perhaps both, I'm open minded).   My site I'm developing is a site with publishing features activated where all my news stories are pages. What I want to have is a sortable list (the type hypothetically achieved using the XsltListView Web Part) the lists these pages with 3 columns visible: The Date created, the title (not the page name), and the author. The tricky part is that I would like the title, when clicked on, to take the person to the page. I'm actually almost there. I've created a new view with these specifications except for one issue. To make the title linked to the page, I have to have the column "URL Path" in my list view. When I remove this column, the titles instead all link to the root of the directory I'm in (ex: if I'm in Pages/Forms/My_List.aspx it will link to Pages/Forms/) Is this a bug, or is the URL Path required for the link to work? Is there a way to hide the column? Thanks.

Performance - page is being loaded for the first time vs SubSequent Request

Hello, I have some serious performance Issues with  Windows controls loading first time on IE Browser then subsequent request's. When ever i open Browser first time , mywebsite takes 7 seconds to load, but on subsequent request  without closing browser it loads with-in 2 seconds.I Knew IIS on first time it re-compiles the process and for subsequent request's  it wont perform and it cahches .I'm looking for better  options to improve performance,  when ever  first time reqest's  comes to web server. On IIS 7  Server,I was using both Dynamic and Static compression enabled.Also,On application pool ,I set "ShutDown Time(Limit)" and "Startup Time(Limit") to 90 (seconds).Here is web.config i disable below to improve performance issues.   <trace enabled="false" pageOutput="false" />    <compilation debug="false"/>   Here is the Server Configuration Windows 2008 ServerIIS 7 64   bit Upto Date patches..Net Framework  2.0,3.0,3.5   Need   inputs to improve performance when user call website for  first time...

Use ASP Request.QueryString in SQL Select Clause... can I?


I want to use the QueryString to specify the column names in the SQL Select expression of <asp:SqlDataSource.

One of several data bases I referr to in the select clause has the columns:


pres, sep, temp, torn are the possible values transmitted by the Query String for the column "Seccion"

Is there an elegant way to bind the column names to the Query String?

Something like MOSS_Personal.horas_<%=Request.QueryString["Seccion"] %>... which is unfortunatly not working!


String encryption problem with request.querystring (urlencode/decode)


I need to pass a userid as a guid number through a url quesrystring

 my starting GUID is in string format =  "23c6e6a5-e9fc-4fd0-aa15-e5db9b900388"

1) I encrypt it using tripledes

the resulting string value =  "nJYKpGwOeoOWepKPSDyNnO+xk+ZcfYZnyxvAnKTNCMV/ZJ7CfDKcmA=="

if I immeadiately decrypt it get the expected original value (so my tripledes provider is working)

2) I then urlencode the value for placing into the url which results in:

urlencoded = "nJYKpGwOeoOWepKPSDyNnO%2bxk%2bZcfYZnyxvAnKTNCMV%2fZJ7CfDKcmA%3d%3d"

3) when a read it back from the url using Request.QueryString (a function which automatically decodes the value)

I get the value: "nJYKpGwOeoOWepKPSDyNnO xk ZcfYZnyxvAnKTNCMV/ZJ7CfDKcmA=="

It appears the "+" characters where replaced with " "

This incorrect value caused the tripledes decryption to fail.
I am using VS 2010 Framework 4.0, IIS7, IE8 and the System.Security.Cryptography.TripleDESCryptoServiceProvider

Is this a bug or am I doing something wrong. It appears the the problem is with the urlencode or the embeded urldecode which is part of request.querystring

Many thanks for any assistance in how to resolve this.


Request is redirected to default Web-Service page (possible cookie issue)


I have a strange problem on my web-service application:
 - when I am initating a web-service request from my client app, no matter if I am using IIS or ASP.NET development server, I'm getting the folowing exception:


System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '


    <head><link rel="alternate" type="text/xml" href="/TestWebSvc.asmx?disco" />

    <style type="text/css">
        BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; }
        #content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; }


 - in my client's app.config file I have pointed to an address like the following one: http://localhost/WebSvc/TestWebSvc.asmx .

 - I have installed SnifferHttpModule (http://geekswithblogs.net/robp/archive/2008/05/13/creating-a-sniffer-for-asp.net.aspx) to see the requests and responses of my web-service,

Transfer values from one page to another Request Object



I wanTransfer values from one page to another using Request Object

but when i try store

textBox value into Request object like..

Request["Name"] = txtName.Text;

i get the following Error

Property or indexer 'System.Web.HttpRequest.this[string]' cannot be assigned to -- it is read only

Is Request object allows us to store values init like Session & Application Object............

extra request to a default page on a callback


Hello guys,

I have a following issue on production server (the development environment is free of it) And it's only happening in Internet Explorer.

I add callback to a page in the old-fashioned way -> Page.ClientScript.RegisterClientScriptBlock(...)

The scenario is:

1) The default page is being loaded. On Page_OnLoad it assigns a NULL to some session key. Let's call it Control -> Session["Control"] = null;

2) User presses a button and gets redirected to a next page (let's call it NextPage.aspx) using javascript event -> window.location.assign(....) (also tried .href = ... - no help)

3) The NextPage.aspx assigns some value to Session["Control"] on Page_OnLoad

5) User clicks a button on the NextPage.aspx and a callback request is being sent to a server....

TA DA!!! The interesting part:

6) Along with the request to the NextPage.aspx another request is being sent to the default page.

7) The only response is being recieved by a client is a response from the NextPage.aspx BUT since the code on the default page is being executed it puts null to the Session["Control"] which screws all my following scenario. the default page doesn't recognize the request as a callback? so if(IsCallback) {} doesn't he

Transfer values from one page to another Request Object



I want to Transfer values from one page to another using Request Object

but when i try store

textBox value into Request object like..

Request["Name"] = txtName.Text;

i get the following Error

Property or indexer 'System.Web.HttpRequest.this[string]' cannot be assigned to -- it is read only

Is Request object allows us to store values init like Session & Application Object............
Taha Zubair Ahmed Software Emgineer.

HttpContext.Session A potentially dangerous Request.QueryString value was detected from the client


I have an ashx handler that was working fine in VS2008 but when I upgraded to VS2010 (haven't gone back to VS2008 to double check though) and when I try to grab the value from HttpContext.Request.Params["update"] I get the following error:

+ ex {"A potentially dangerous Request.QueryString value was detected from the client (update=\"<SETIProducts><Produ...\")."} System.Exception {System.Web.HttpRequestValidationException}

"A potentially dangerous Request.QueryString value was detected from the client (update=\"<SETIProducts><Produ...\")."} System.Exception {System.Web.HttpRequestValidationException}

I've read that I can set the validateRequest to false, but I was wondering about the impacts and looking for any other suggestions. 

I know very little about security when it comes to web programming but I thought I should mention that my handler will be running on a internal file server but transmitting data to/from an eCommerce platfo

Virtual path provider to have custom path tokens in master page references


I managed to port Asp.net MVC to run in a Sharepoint site (only inside a particular folder not everywhere) by:

  1. Writing an IHttpModule that I use to register routes, areas, view engine and virtual path provider inside the Init method, that is called only once per application life hence it works like an application_start event
  2. Writing a custom URL routing module that only performs routing for a particular subfolder path, all other paths are ignored, so everything else works just as it does and is completely handled by sharepoint
  3. Writing a custom view engine that defines different view/master paths related to the subfolder where MVC is running
  4. Writing a costom virtual path provider that should allow me to reference masterpages based on my configured subfolder where MVC is running.
  5. Adding a virtual folder (without assigning it an application) to my Sharepoint's site, so my app will be running as part of Sharepoint site and not as a separate application
  6. Customizing Sharepoint site's config to add my MVC application's configuration, adding MVC assemblies to compilation section, adding namespaces to <pages> element so I my view will see Html helpers, and adding two modules (my intialization module that registers routes etc) and subfolder routing module.

But I would like to accomplich

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend