Wednesday, February 9, 2011

Remote Desktop ASPX from WHS 2003

I got a (HP) Window Home Server at home for a long time. Previously, I was just using it as file server and never thought of using it as a IIS server. Last month, my wife was working on a web project and asked me there is any free web hosting service on line or not so that she doesn't need to pay anything for just trying out her web site. Because of that reason, I started searching around and found a tool called "WHIIST" for Home Server. I'm not going to talk about this tool since there are many information from the internet about this tool and if you want, you can go to the official website to download and try it. (Beside, I just found out Andrew is not going to write the WHIIST for WHS VAIL. What a bad news!)

Having WHIIST installed on my home server gives me a lot of freedom and a lot of possibilities. After I installed WHIIST, SQL 2008, and .NET 4.0 framework on the server, I can now host my WebMatrix project on my home server and access it from the web. (I will talk about on how to configure the IIS and .NET 4.0 framework for WebMatrix later) However, one of the limitation from home server is that the remote desktop from the remote desktop page doesn't bring me to the desktop, instead, it brings me to the Home Server Console! Remote into the Home Server Console doesn't help me a lot in terms of configuring the IIS or the File. Therefore, I need to find a way to remote to the desktop. In order to do that, we need to edit the rdpload.aspx file.

By default, when you try to remote into the server you will get route to the Home Server Console:

































However, we can edit the rdpload.aspx file so that it doesn't route us to the Home Server Console.

Open the file by using NotePad and find the following line:

/* Comments*/
MsRdpClient.SecuredSettings.StartProgram = "HomeServerConsole.exe -b";
MsRdpClient.SecuredSettings.WorkDir = "<%= WorkDir %>";
And replace those 2 lines with the following:

/* Comments*/
MsRdpClient.SecuredSettings.StartProgram = "Explorer.exe";
MsRdpClient.SecuredSettings.WorkDir = "c:\\Windows";
Once you are done, save the file and try the remote desktop function from your remote page. If nothing goes wrong, it should route you to the desktop:


















As you can see, we can edit the file to enable the full-screen viewing rather than viewing it in a block. I'm going to stop here and leave the option on you to continue editing the file to find other possibilities.

Thursday, February 3, 2011

.NET requestValidationMode

I'm not sure how often other people have this kind of problem but when I decided to update my blog with "<" or ">" character, I have to find a HTML Encoder tool to encode the character. Since I have a window home server at home, I decided to write my own on-line HTML encoder page.

I have finished the web site and I host it on my home server. The web site is written by .NET 4.0 (I know it doesn't need to do with .NET..) and you can try it by clicking HERE

The syntax to encode the HTML text is really simple:

/* Comments*/
protected void Button1_Click(object sender, EventArgs e)
{
String value = "";
value = InputTxt.Text.Trim();
EncodedTxt.Text = "";
EncodedTxt.Text = Server.HtmlEncode(value).Trim();
}
To convert the text is really simple. However, the issue I had is about the HTML Request Validation. Once I have all the codes ready, I tried to run the page on my PC and test it by pasting "<header></header>". By clicking the button to trigger a page postback, I got the following error message:






After I did some research about this message, I figured out the error message I was having is because MS has a Request Validation to check the request contains any "Script" or not. For me, I have to disable the validation in order to perform the encoding. There are different ways to disable this validation. I choose to edit the web.config to disable the validation.

To disable the validation by editing the web.config file, open the web.confg file and update it like the following:
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>
After I updated the web.config file, I'm able to perform the encoding.