如何在ASP.NET网站中添加引用 [英] How do I add a reference in my ASP.NET website

查看:101
本文介绍了如何在ASP.NET网站中添加引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站上使用以下代码

HttpWebRequest request =(HttpWebRequest)WebRequest.Create(url);

我正在使用visual studio 2012

我收到错误

I am trying to use the following code in my website
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
I am using visual studio 2012
I get the error that

Error   1   The type or namespace name 'HttpWebRequest' could not be found (are you missing a using directive or an assembly reference?)  



我知道我需要添加一个参考。当我按照以下步骤添加引用时出现问题。

我右键单击解决方案资源管理器中的站点名称,然后单击添加 - 单击引用。出现一个对话框。我单击System.Net.Http并单击System.Net.Http.WebRequest。这些方框有刻度标记。然后我按OK

我希望添加引用,但我没有看到任何参考和错误的继续显示。



请帮助我建议我在添加参考时犯的错误。



非常感谢您的帮助


I know that i need to add a reference. I get problem while adding reference when i follow the following steps.
I right click on the site name in Solution explorer and click on add - click on reference. A dialogue box appears. i click on System.Net.Http and also click on System.Net.Http.WebRequest. The boxes are tick - marked. Then i press OK
I expect the reference to be added but i do not see any addition of reference and error continues to display.

Kindly help me advising what mistake i am making in adding reference.

Many thanks for your help

推荐答案

右键单击HttpWebRequest,然后从上下文菜单中选择Resolve。在解析菜单下,将有一个选项用于添加正确的使用(使用System.Net),因此选择它。
Right-click on HttpWebRequest and from the context-menu select Resolve. Under the resolve menu there will be an option for adding the correct using (using System.Net) so select that.


HttpWebRequest在System.Net中,https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest (v = vs.110).aspx [ ^ ]。



如果您将其作为参考,则添加using语句。你应该得到一点蓝色(我记得)在错误所在的代码行的开头下面。将鼠标悬停在该位置上,它应该建议添加使用,您只需单击它即可为您执行此操作。
HttpWebRequest is in System.Net, https://msdn.microsoft.com/en-us/library/system.net.httpwebrequest(v=vs.110).aspx[^].

If you have that as a reference then add the using statement. You should also get a little blue (as I recall) underline underneath the beginning of the line of code where the error is. Hover over that, and it should suggest adding the using which you can just click it to do it for you.


这篇关于如何在ASP.NET网站中添加引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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