如何获取URL当前页面的URL? [英] How can I get the URL of the current page of the URL?

查看:144
本文介绍了如何获取URL当前页面的URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取网址当前页面的网址? (IE + FIREFOX + CHROME)它是什么?

每个人都告诉我们使用followin gcode:

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();
    }
}





但是在给出错误HttpContext在当前比赛中并不存在。我正在使用控制台应用程序以下链接与我的问题相同:

http://stackoverflow.com/questions/593709/how-to-get-the-url-of-the-current-page-in-c-sharp [<一个href =http://stackoverflow.com/questions/593709/how-to-get-the-url-of-the-current-page-in-c-sharptarget =_ blanktitle =New Window > ^ ]



任何人都可以帮助我吗?

谢谢



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

推荐答案

由于未使用正确的.NET配置文件而收到的错误。有一个.NET客户端配置文件(轻量级)和一个完整的配置文件(完整的.NET功能)。这是您可以在项目的属性中设置的内容。从您发布的内容中我收集了设置,使您的项目使用.NET客户端配置文件。

另外还有一件事是您希望 HttpContext.Current.Request.Url.AbsoluteUri 要有合理的价值。你编写的程序是一个控制台应用程序,所以你期望URI是什么?



无论如何,要摆脱编译错误,你将不得不在项目设置中将.NET配置文件从客户端更改为完整版。



问候,



- Manfred
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


这篇关于如何获取URL当前页面的URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆