Click here to Skip to main content
11,921,316 members (61,751 online)
Rate this:
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;

But is giving error "HttpContext" doesn't exist in current contest. I am using console application. Following link is same as my problem:[^]

Can any one help me?
Posted 25-Mar-13 4:50am
ryanb31 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 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 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 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
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.


— Manfred

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

  Print Answers RSS
0 OriginalGriff 583
1 Dave Kreskowiak 245
2 phil.o 160
3 KrunalRohit 134
4 F-ES Sitecore 130
0 OriginalGriff 6,951
1 KrunalRohit 4,530
2 Sergey Alexandrovich Kryukov 3,171
3 George Jonsson 2,840
4 Suvendu Shekhar Giri 2,181

Advertise | Privacy | Mobile
Web01 | 2.8.151120.1 | Last Updated 25 Mar 2013
Copyright © CodeProject, 1999-2015
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