.netの最近のブログ記事

最初できないかと思ったけど、WebExceptionのResponseプロパティで取得できた。
HttpWebRequest.GetResponse()は、ステータスコードが2xx以外の場合は例外WebExceptionを投げるようである。例外をcatchしてResponseを見ればよい。

HttpWebResponse response = null;
try
{
    response = (HttpWebResponse)myHttpWebRequest.GetResponse();
}
catch (WebException e)
{
    response = (HttpWebResponse)e.Response;
}

// Get the stream associated with the response.
Stream receiveStream = response.GetResponseStream();

// ...以下略


.Net HttpWebRequest.GetResponse() raises exception when http status code 400 (bad request) is returned - Stack Overflow

カテゴリー:

カテゴリー:

カテゴリー:

カテゴリー:

カテゴリー:

カテゴリー:

カテゴリー:

カテゴリー:

Visual Studio 2005で、アプリケーション起動時にUACの昇格ダイアログを表示させる方法。
(Visual Studio 2008ならもっと簡単。)

Step 6: Create and Embed an Application Manifest (UAC)

Professional Visual Studio » Enabling Your Application for UAC

yourapp.exe.manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <ms_asmv2:trustInfo xmlns:ms_asmv2="urn:schemas-microsoft- 
     com:asm.v2">
      <ms_asmv2:security>
         <ms_asmv2:requestedPrivileges>
            <ms_asmv2:requestedExecutionLevel level="requireAdministrator">
            </ms_asmv2:requestedExecutionLevel>
         </ms_asmv2:requestedPrivileges>
      </ms_asmv2:security>
   </ms_asmv2:trustInfo>
</assembly>
post build task in your Visual Studio project's Project Properties:
"$(FrameworkSDKDir).\Bin\mt.exe" -nologo -manifest "$(ProjectDir)$(TargetFileName).manifest" -outputresource:$(TargetPath);#1"
or
mt.exe -manifest "$(ProjectDir)$(TargetName).exe.manifest" -updateresource:"$(TargetDir)$(TargetName).exe;#1"

カテゴリー:

Tips & Tricks for ASP.NET, IIS, and Visual Web Developer : Tip #51 Did you know... how to use VS2005 to debug with IE8?

1) Open RegEdit
2) Browse to HKEY_LOCALMACHINE -> SOFTWARE -> Microsoft -> Internet Explorer -> Main
3) Add a dword under this key called TabProcGrowth
4) Set TabProcGrowth to 0

カテゴリー: