Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
C#
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
Comments
ZurdoDev 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?
iDebD 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.
iDebD 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

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
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900