3.16.2010

.NET 4.0 Serializing IDictionary

Yes, now we can serializing the object which contain or implement of IDictionay in .NET 4.0.

The different part of code is change to using System.Xaml namespace and the code is more simple, for instance:

using (StreamWriter stream = newStreamWriter("C:\\data.xml")) {
    stream.Write(
XamlServices.Save(data));
}

Now the I have to reconsider the power of the web service…

 

現在我們可以在.NET4.0 的程式碼中Serializing(序列化)含有IDictionary或是繼承自他的物件.

差異的地方是我們必須引用System.Xaml, 新的序列化服務的寫法也變簡單了, 請參考下面程式碼:

using (StreamWriter stream = newStreamWriter("C:\\data.xml")) {
    stream.Write(
XamlServices.Save(data));
}

嘖嘖嘖..我現在要好好想想web service的威力了….

3.08.2010

System.Net.WebException: The request failed with HTTP status 503: Service Unavailable

Background:

  1. ASP.NET application (Web from or call another ASP.NET web service) in IIS6
  2. Complicated network environment
  3. Several web front ends
  4. Every web service call return 503…

Maybe you can try to setup the Internet Explorer proxy settings to bypass every web front end, and also downgrade the IIS from Kerberos to NTLM, and try it again.

Internet Explorer configuration :

  1. Tools –> Internet Options
  2. Connections Tab –> LAN Settings
  3. “Advanced” button inside “Proxy Server” group
  4. Add the web front ends’ domain name into the “Exceptions”

How to downgrade from Kerberos to NTLM:

  1. Open command prompt
  2. Change directory to “C:\Inetpub\Adminscripts
  3. Input:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "NTLM"
  4. About WebSite, it is web site id, you can find it by fowllowing steps:
    1. Open Internet Information Services (IIS) Manager
    2. Click “Web Sites”, and you can found the value in the Identifier column
  5. Input as following command then you can rollback to Kerberos:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "Negotiate,NTLM"

 

狀況:

  1. ASP.NET 應用程式呼叫ASP.NET web service, IIS6
  2. 網路環境有點複雜, 而且離我超遠
  3. 很多台web front end
  4. 隨便Call web service都回你503

我後來是這樣解的, 先把所有的web front end server都列入直接連線的部分, 接下來再把所有的web front end的IIS通通設定成NTLM. 先求可以通, 這樣回到Kerberos才有機會跟網管那邊確認問題.

怎麼設定bypass proxy server

  1. 打開IE, 工具->網際網路選項
  2. “連線” 那個頁籤, 選區域網路設定
  3. 按那個進階的按鈕
  4. 在那個例外裡面輸入web front end server的domain name

怎麼將IIS的Authentication設定成NTLM

  1. 打開”命令提示字元”
  2. 將路徑轉換到 “C:\Inetpub\Adminscripts
  3. 輸入:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "NTLM"
  4. 那個WebSite就是站台的ID, 要找的話打開IIS管理工具, 然後點站台, 右邊就會有欄位顯示出來了
  5. 要倒回去Kerberos, 輸入下列命令即可:
    cscript adsutil.vbs set w3svc/WebSite/root/NTAuthenticationProviders "Negotiate,NTLM"

2.26.2010

Visual Studio 2010 and 64x

The Redmond company is sticking with a 32-bit exclusive strategy for Visual Studio, at least for the time being, even though it is well aware that 64-bit architectures are becoming mainstream. <----sigh

 

這家位在Redmond的公司在Visual Studio上將繼續維持32-bit only的策略, 就算64-bit看來一定會是市場的主流. (link點上面那一個) <-- 嘆

1.31.2010

UNC and HttpContext.Current.User

If your ASP.NET web site running in a UNC location, and also running the site with windows integrated authentication.

And now, you are trying to get the Http.Current.User. You will get the account who running for Application pool whatever you login for test. I found the only way to get real login account is using Request.ServerVariables[“LOGON_USER”].

Environment: IIS6.0, Umbraco

Does anyone have another solution?

Remove Server From MOSS Farm

There are four way to remove the server from MOSS server farm.

  • First one is disconnect by running the configuration wizard from the start menu. This is the same way to use if you want to leave MOSS 2007 installed on the server but disjoined from the farm.
  • Second on is removes the server if you want to clean up the serer when it can contact the configuration database. This method also uninstalls the SharePoint from the server.
    • ​Use Add/Remove Programs in the control panel.
    • In "Add/Remove Programs", you can remove "Microsoft Office SharePoint 2007", and it wills pop-up a warning, Click Ok to continue.
  • The third method is removing the server from the server farm in the SharePoint Central Administration site. This way is easy and quickly, almost no latency, the action was completed. But this way don’t disconnect the server from the SharePoint database.
  • The last method is more advanced, it will disconnecting the server from the SharePoint configuration database. And then you can format the server or re-install MOSS, whatever you want for the server. The step is very easy:
    • Open a command prompt to c:\program files\common files\Microsoft shared\web server extensions\12\bin (the SharePoint installed path)
    • Run following command:
      psconfig –cmd configdb –disconnect

Actually, I do server remove by the three and last one method, remove the server from MOSS farm by Central administration site, and then disconnected the server from configuration database. It is easy and cleanly, and without reset anything/reboot machine.

8.19.2009

Runas in the machine don’t join domain

My laptop don’t join the company domain. Sometime I want to run a application as my domain account in the company domain to access the resource in the company domain, but the menu only existing “Run as administrator” when I right click the shortcut of the application.
How to resolve this?

There are two way I using to do Run As. One is ShellRunas v1.01, here is the detail description from Norm.

Another one is runas command in command prompt. Here is the syntax:

runas [{/profile|/noprofile}] [/env] [/netonly] [/smartcard] [/showtrustlevels] [/trustlevel] /user:UserAccountName program

It will easy to run the application as the account you have password.

If you encounter error by the command, please check do you accessed the machine by the account before first. That is because some program (as Visual Studio) running with account profile/env.

Change the connection string at runtime

I am doing a new project which try to utilize Quartz.Net to schedule the change of content base on Spring.Net and nHibernate.

The simple map is we have a regular process to deal with user’s request to change the content in the authoring environment and also input a schedule job into database by Quartz.Net. Another process, based on Windows Service will check the jobs queue, if the job startup time is up, then the process will update the content in the publish environment.

Seems the function is easy to implement. But we are frustrating for the timer job process to change database connection since the service module was based on Spring.Net and NHibernate.

After do some research and study, we finally found the solution to change connection string at runtime. (Beside this, actually there has another way to implement this function, by dual database provider).

This discussion thread detail the function implementation, and here is a great sample.