HttpWebRequest not sending UserAgent

前端 未结 1 482
余生分开走
余生分开走 2021-01-20 01:44

I\'m new to looking at the whole Web side of .net, and I\'ve run into a slight issue.

I\'m trying to do a HttpWebRequest as below:

String uri = \"h         


        
相关标签:
1条回答
  • 2021-01-20 02:22

    I don't think that you are looking at the correct Fiddler line. What you have shown is a CONNECT verb, not GET. The UserAgent should be properly set using the request.UserAgent property. Another way to debug the request is to configure network tracing at your application level which I personally prefer compared to Fiddler:

    <configuration>
        <system.diagnostics>
            <sources>
                <source name="System.Net" tracemode="protocolonly" maxdatasize="1024">
                    <listeners>
                        <add name="System.Net"/>
                    </listeners>
                </source>
            </sources>
            <switches>
                <add name="System.Net" value="Verbose"/>
            </switches>
            <sharedListeners>
                <add 
                    name="System.Net"
                    type="System.Diagnostics.TextWriterTraceListener"
                    initializeData="network.log"
                />
            </sharedListeners>
            <trace autoflush="true"/>
        </system.diagnostics>
    </configuration>
    
    0 讨论(0)
提交回复
热议问题