Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# .NET
How can I get the URL of the current page of the URL? (IE + FIREFOX + CHROME) what ever it is?
Every one tellin gme to use followin gcode:
using System;
using System.Web;
 
public class Program
{
    public static void Main()
    {
        Uri MyUrl = HttpContext.Current.Request.Url.AbsoluteUri;
        Console.ReadKey();
    }
}
 
But is giving error "HttpContext" doesn't exist in current contest. I am using console application. Following link is same as my problem:
http://stackoverflow.com/questions/593709/how-to-get-the-url-of-the-current-page-in-c-sharp[^]
 
Can any one help me?
Thanks
Posted 25-Mar-13 4:50am
iDebD842
Comments
ryanb31 at 25-Mar-13 9:53am
   
How can a console application get the current URL? URL of what? A console app does not have a url. HttpContext is in a web application, very different than a console app.
Rohit Kumar Mumbai at 25-Mar-13 10:02am
   
Can you please explain how you are using console application to Get Web Page URL?

Which URL you are trying to get from console application?
bubaidada at 26-Mar-13 1:17am
   
I was wrong. I am trying to write a console application whick will grab all urls currently open in all browsers.
bubaidada at 25-Mar-13 10:18am
   
Okk...Got your point.. Actually I have very limited knowledge in this domain. I have to find another method..I was going in a wrong way..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

The error you are receiving due to you not using the correct .NET profile. There is a .NET client profile (light) and a full profile (complete .NET functionality). This is something you can set in your project's properties. From what you posted I gather the setting made your project use ".NET Client Profile".
A competely other thing is that you expect HttpContext.Current.Request.Url.AbsoluteUri to have a sensible value. The program you wrote is a Console application, so what would you expect the URI to be?
 
Anyway, to get rid of the compilation error you'll have to change the .NET profile from client to the full version in your project's settings.
 
Regards,
 
— Manfred
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 25 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100