473,396 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Adding Headers in ASP.NET on vista

Hi,

I had the following code running fine on my xp box. Then, I got a
vista box and now I get a "PlatformNotSupportedException" when I try
to add the header. I do know that now in IIS7 there are different ways
to do things, but I have the issue of deploying to IIS6 servers.

//get a reference
NameValueCollection headers =
HttpContext.Current.Request.Headers;
//get a type
Type t = headers.GetType();
//get the property
PropertyInfo p = t.GetProperty("IsReadOnly",
BindingFlags.Instance | BindingFlags.IgnoreCase
| BindingFlags.NonPublic |
BindingFlags.FlattenHierarchy);
//unset readonly
p.SetValue(headers, false,null);

//add a header
//This breaks in vista
headers.Add("SID", "1234"));

It blows up on the last line. I am using the built in webserver for vs.
2005, but I do have IIS installed on vista.
This code is just in an http module that gets ran as a request is
coming in. Again, it worked fine on my xp box. Any ideas are
appreciated.

Jul 6 '07 #1
5 2243
The request collection is read only; you simply can't change the
request from your client, and I'm not sure why you would want to, and
I'm not sure why this ever worked, as you indicate.

You can edit the _response_, but not the request.

Good Luck,

-Mark

Jul 8 '07 #2
On Jul 7, 11:20 pm, "Mark S. Milley, MCSD (BinarySwitch)"
<mark.mil...@binaryswitch.comwrote:
The request collection is read only; you simply can't change the
request from your client, and I'm not sure why you would want to, and
I'm not sure why this ever worked, as you indicate.

You can edit the _response_, but not the request.

Good Luck,

-Mark

I am using an HTTPModule to analyze incoming urls and pass a variable
along to the app. I had been using headers because it seemed fairly
clean, but I am open to any suggestions at all.

1) I need to look at a url like:
www.xyz.com/madeUpDirectory/
2) I need to find an ID based on madeUpDirectory
3) I need to pass that ID along to my app.

The user still sees
www.xyz.com/madeUpDirectory, but that in fact doesn't exist.

I had it all worked out using xp/Server 2003, but again vista blows
up.

Do you have an idea for the most appropriate way to pass this data
along? Request.QueryString is read only as well.

Thanks
-Mike

Jul 9 '07 #3

Hi Mike -

Just do a Response.Redirect. The user shouldn't see the difference on
their end.

Response.Redirect(string.format("pathtoredirectto? myarg={0}",myparam)

However, out of curiosity, why even pass this along in the
querystring? Can't you just as easily extrapolate the request from the
code that is going to use the resultant variable?

In other words, iin your sub, instead of looking for
request.querystring("myarg"), determine, at that point, what the
requesting path is. If that's inconvenient, you can always create a
private member variable to hold the parameter, and set the value on
the page_load to reuse throughout the page.

Good luck,

-Mark

Jul 9 '07 #4
Mark,
I think I will go with your last suggestion. I have an odd situation
where I have to parse the url and sometimes rewrite it and sometimes
do nothing. The only downside I can see is that I have to parse the
url twice: 1) parse it to see if I need to do anything, 2) if I
rewrote the url then reparse to get the variable info.

I had hoped to avoid this by setting the header, but it certainly
isn't the end of world if I can't. I appreciate you taking the time to
offer suggestions. I think I will take the last approach you
mentioned.

Thanks again.
-Mike
On Jul 9, 10:10 am, "Mark S. Milley, MCSD (BinarySwitch)"
<mark.mil...@binaryswitch.comwrote:
Hi Mike -

Just do a Response.Redirect. The user shouldn't see the difference on
their end.

Response.Redirect(string.format("pathtoredirectto? myarg={0}",myparam)

However, out of curiosity, why even pass this along in the
querystring? Can't you just as easily extrapolate therequestfrom the
code that is going to use the resultant variable?

In other words, iin your sub, instead of looking forrequest.querystring("myarg"), determine, at that point, what the
requesting path is. If that's inconvenient, you can always create a
private member variable to hold the parameter, and set the value on
the page_load to reuse throughout the page.

Good luck,

-Mark

Jul 10 '07 #5
Hi Mike -

Glad I could help...

-Mark

Jul 16 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Cybermedia Marketing | last post by:
I'm trying to convert an ISAPI filter to an httpmodule. The ISAPI filter added custom headers to the response which could later be accessed by the asp page. ISAPI Filter: ...
1
by: Ale News | last post by:
Hi to All.. I must add some custom headers HTTP and then i would to read them.. I used the AppendHeader Method to add my headers but when i try to read the headers i can't see my custom ones.....
0
by: Stephen Hynds | last post by:
Hi, I'm writing a VB app that sends mail to a number of users when an important deadline is approaching. I can get the mail to show up as high priority and I can even get it to have a follow up...
4
by: razvan | last post by:
I need advice about adding security to a web service without using WSE, as the clients will run Win98.
1
by: asnowfall | last post by:
I am creating MailMessage out of already existing email message. My existing message has few custom properties. I wan to add them to System.Net.Mail.MailMessage How to add custom properties? ...
0
by: Sanjaya | last post by:
Hi, I need to add application specific headers and reference parameter in the "ReplyTo" to my web service request as header elements. What is right way to do this? I'm using framework 1.1 with...
0
by: Nithi Gurusamy | last post by:
I have generated a Web-Service-Proxy (Add Web Reference) within VS. This proxy class is based on WebServicesClientProtocol of WSE 3.0. I want to add some custom HTTP Headers to the envelop before...
1
by: =?Utf-8?B?RXZlcnQ=?= | last post by:
When adding a vista ultimate pc to a domain i get the following message " There is no user session key for the specified logon session." I am not able to find the error. Network is available,...
2
by: =?Utf-8?B?QnJhc3NpY2FOaWdyYQ==?= | last post by:
Greetings, Recently I upgraded to Windows Vista Ultimate and VS2008 with SQLExpress 2008. For the last several years I have been using Windows XP SP2 and VS2005 with SQLExpress 2005. All of...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.