[W8.1] [C#]无法在HttpWebRequest中设置用户代理值以从Windows 8.1应用程序中访问Web Api。 [英] [W8.1][C#] unable to set the User Agent value in HttpWebRequest to hit the Web Api from windows 8.1 application.

查看:82
本文介绍了[W8.1] [C#]无法在HttpWebRequest中设置用户代理值以从Windows 8.1应用程序中访问Web Api。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows 8.1应用程序试图点击一个web api方法,但是它给出了错误代码403.

I have a windows 8.1 application which try to hit a web api method but it gives error code 403.

由于httpwebrequest属性中的空值而导致错误。当我尝试在请求标头中设置User-Agent值但无法设置时。

The error is comming due to null value in httpwebrequest property.When i am try to set the User-Agent value in request header but unable to set.

我们如何在httpwebrequest中设置User-Agent值 对于Windows 8.1应用程序?

How we can set the User-Agent value in httpwebrequest  for windows 8.1 application ?




推荐答案

Hello Suraj Yadav ,

Hello Suraj Yadav,

您可以根据此页面编辑标题标签
https://social.msdn.microsoft.com/Forums/windowsapps/en-US/b479e984- ca39-4b34-a6b7-85194b54d8bd / guide-to-posting-subject-line-tags?forum = wpdevelop

Can you edit your title tag based on this page https://social.msdn.microsoft.com/Forums/windowsapps/en-US/b479e984-ca39-4b34-a6b7-85194b54d8bd/guide-to-posting-subject-line-tags?forum=wpdevelop

所以你在Windows 8.1 Universal上app,我是对的吗?

So you are on a Windows 8.1 Universal app, am I right?

如果是这样,请参考以下内容:
https://stackoverflow.com/questions/7454301/is-it-possible-to-modify-the-user-agent -for-a-winrt-httpwebrequest
但请理解,在Windows 8.1平台上,您的HttpWebRequest API很差,实际上我建议您升级为使用UWP
pl atform。您将有更多API可供使用。

If so, please refer to this so thread: https://stackoverflow.com/questions/7454301/is-it-possible-to-modify-the-user-agent-for-a-winrt-httpwebrequest But please understand that on Windows 8.1 platform your HttpWebRequest API is poor and actually I would recommend you to upgrade to use UWP platform. You will have more API available to use.

祝您好运,

Barry


这篇关于[W8.1] [C#]无法在HttpWebRequest中设置用户代理值以从Windows 8.1应用程序中访问Web Api。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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