473,813 Members | 4,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems using HttpContext.Cur rent.Request.Ur l.Host

I am having problems using HttpContext.Cur rent.Request.Ur l.Host.

I have some code that does this...

if (HttpContext.Cu rrent != null)
{

subdomain = HttpContext.Cur rent.Request.Ur l.Host;

}

Now if I put a break point on the if statement I get this error for the
HttpContext.Cur rent.Request. Request: 'HttpContext.Cu rrent.Request' threw
an exception of type 'System.Web.Htt pException'

Now if I comment out the subdomain = HttpContext.Cur rent.Request.Ur l.Host;
and stop at the same break point it works fine.

Now this seems to be a problem with the 3.5 framework because after I
installed it, this code seemed to not work any more.

Any idea's?

TIA,
Brett

Feb 28 '08 #1
3 13478
Brett,

Well, what is the message that is thrown with the exception? That would
help quite a bit.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brett R. Wesoloski" <br*********@pl anadmininc.comw rote in message
news:39******** *************** ***********@mic rosoft.com...
>I am having problems using HttpContext.Cur rent.Request.Ur l.Host.

I have some code that does this...

if (HttpContext.Cu rrent != null)
{

subdomain = HttpContext.Cur rent.Request.Ur l.Host;

}

Now if I put a break point on the if statement I get this error for the
HttpContext.Cur rent.Request. Request: 'HttpContext.Cu rrent.Request' threw
an exception of type 'System.Web.Htt pException'

Now if I comment out the subdomain = HttpContext.Cur rent.Request.Ur l.Host;
and stop at the same break point it works fine.

Now this seems to be a problem with the 3.5 framework because after I
installed it, this code seemed to not work any more.

Any idea's?

TIA,
Brett

Feb 28 '08 #2
Yes sorry about that.

the message is Request is not available in this context.

Error Code: -2147467259

Stack Trace: a system.web.http context.get_req uest()
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c omwrote in
message news:O1******** ******@TK2MSFTN GP03.phx.gbl...
Brett,

Well, what is the message that is thrown with the exception? That
would help quite a bit.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Brett R. Wesoloski" <br*********@pl anadmininc.comw rote in message
news:39******** *************** ***********@mic rosoft.com...
>>I am having problems using HttpContext.Cur rent.Request.Ur l.Host.

I have some code that does this...

if (HttpContext.Cu rrent != null)
{

subdomain = HttpContext.Cur rent.Request.Ur l.Host;

}

Now if I put a break point on the if statement I get this error for the
HttpContext.Cu rrent.Request. Request: 'HttpContext.Cu rrent.Request'
threw an exception of type 'System.Web.Htt pException'

Now if I comment out the subdomain =
HttpContext.Cu rrent.Request.U rl.Host; and stop at the same break point it
works fine.

Now this seems to be a problem with the 3.5 framework because after I
installed it, this code seemed to not work any more.

Any idea's?

TIA,
Brett

Feb 28 '08 #3
the message is Request is not available in this context.

OK; so what *is* the context - i.e. where is this code, and when does
it run? i.e. is it part of a standard ASP.NET pipeline, or something
more exotic?

For the record, *if* this changed when you installed 3.5, then in
reality it is probably a change in "2.0 SP1", not 3.5. I mention this
simply because if it *is* a breaking change, you might need to watch
out for people installing "2.0 SP1" until you have fixed the offending
code.

Marc
Feb 29 '08 #4

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

Similar topics

2
1178
by: pietaster | last post by:
I really dont know what I should do. I am asking for best practices. currently I create my properties by doing this. Context.Items.Add("Info", new Info(Request.QueryString, Request.QueryString)); Info is a class that I call that places all data retrieved from a db into public properties.
10
7947
by: Anthony Williams | last post by:
Hi gang, This one looks like a bug :o( As you may or may not know, setting session management in web.config to use cookieless sessions causes the ASP.NET runtime to munge a session ID into the URL, in the format http://yourapplicationpath/(Session.SessionID)/... which saves numerous headaches when it comes to storing state across page requests and sessions.
2
2155
by: | last post by:
Today I learned that creating cookies inside of a custom class in ASP.NET 2.0 requires that you prefix it with HttpContext.Current..., e.g. : HttpContext.Current.Response.Cookies.Add("myNewCookie"); I am wondering if there are any landmines that I should know about, or if this will work pretty much as I am expecting a cookie should.
0
1759
by: Rick Hein | last post by:
I've got a problem with an app I've been working on, the Caching object and events not firing correctly. In a nutshell: When I'm debugging, and I set a breakpoint in the removed item call back, the code works correctly. If there is no debugger it doesn't fire, which causes the app to have problems. Here's what the code does: The TemplateData class inherits from the DataSet Object, in the constructor it loads itself with Data from an XML...
3
2814
by: ExclusiveResorts | last post by:
Can the CallContext be used reliably for storing request specific data? We are developing an application library that uses the CallContext to keep an IdentityMap (hashtable of business objects that have been loaded from the DB) and a collection of business objects that have been modified during the current request. These object maps need to be globally visible throughout a request and expire at the end of it. The maps are accessed using...
3
2950
by: asanford | last post by:
I want to create an ASP.NET web application that receives a form POST message, inspects the data, and reroutes the request to one of many different servers. I wrote an IHttpModule which successfully used HttpContext.RewritePath() to send a request to different pages in one web application, but it gives me an error when I try to rewrite a path to a different web app or server. Does RewritePath() not support this? I can reroute by...
3
7684
by: Jim Lewis | last post by:
I have read several things that state accessing a Web Service through a Query String should work. However, when I try to execute http://localhost/webservice1/service1.asmx/HelloWorld I get the error below. Can I access a Web Service through a Query Sting. I need to send XML to a Flash movie using a Web Service. Thank You, Jim Lewis Server Error in '/WebService1' Application.
1
1800
by: kristian | last post by:
I'm using the following entry in my web.config: web.config <customErrors mode="On" defaultRedirect="~/CMS/Default.aspx"> <error statusCode="404" redirect="~/CMS/Default.aspx"/> </customErrors> And this is in the Global.asax Global.asax void Application_Error(object sender, EventArgs e) {
7
2834
by: =?Utf-8?B?QU9UWCBTYW4gQW50b25pbw==?= | last post by:
Hi, I have been using the code (some of it has been removed for simplicity) below to allow authenticated (using ASP.NET membership database) users to get a file from their archive area. It seems to work fine, however I noticed that no web log entry is added when a successful download occurs (normally a 200 HTTP status code, however, if there is an authorization failure, it gets logged). I have a logging routine that logs a successful...
0
9607
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10406
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10420
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10139
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3881
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3029
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.