Pages

Search This Blog

Wednesday, October 31, 2007

window.location.search

window.location.search is a very useful script that able to return all querystring for further usage like pass to another page/AJAX.

To test on the usage, save below page as locationsearch.htm. To see the result, add querystring to the page called: locationsearch.htm?p=testing&l=javascript

<html>
<head>
<script language="JavaScript">

function onload()
{
alert(window.location.search);
}

</script>
</head>

<body onLoad="onload()">

</body>
</html>

Monday, October 29, 2007

Top 100 living geniuses

Top 100 living geniuses


1=Albert Hoffman(Swiss)Chemist27
1=Tim Berners-Lee(British)Computer Scientist27
3George Soros(American)Investor & Philanthropist25
4Matt Groening(American)Satirist & Animator24
5=Nelson Mandela(South African)Politician & Diplomat23
5=Frederick Sanger(British)Chemist23
7=Dario Fo(Italian)Writer & Dramatist22
7=Steven Hawking(British)Physicist22
9=Oscar Niemeyer(Brazilian)Architect21
9=Philip Glass(American)Composer21
9=Grigory Perelman(Russian)Mathematician21
12=Andrew Wiles(British)Mathematician20
12=Li Hongzhi(Chinese)Spiritual Leader20
12=Ali Javan(Iranian)Engineer20
15=Brian Eno(British)Composer19
15=Damian Hirst(British)Artist19
15=Daniel Tammet(British)Savant & Linguist19
18Nicholson Baker(AmericanWriter18
19Daniel Barenboim(N/A)Musician17
20=Robert Crumb(American)Artist16
20= Richard Dawkins(British)Biologist and philosopher16
20=Larry Page & Sergey Brin(American)Publishers16
20=Rupert Murdoch(American)Publisher16
20= Geoffrey Hill(British)Poet16
25Garry Kasparov(Russian)Chess Player15
26=The Dalai Lama(Tibetan)Spiritual Leader14
26=Steven Spielberg(American)Film maker14
26=Hiroshi Ishiguro(Japanese)Roboticist14
26=Robert Edwards(British)Pioneer of IVF treatment14
26=Seamus Heaney(Irish)Poet14
31Harold Pinter(British)Writer & Dramatist13
32=Flossie Wong-Staal(Chinese)Bio-technologist12
32=Bobby Fischer(American)Chess Player12
32=Prince(American)Musician12
32=Henrik Gorecki(Polish)Composer12
32= Avram Noam Chomski(American)Philosopher & linguist12
32=Sebastian Thrun(German)Probabilistic roboticist12
32=Nima Arkani Hamed(Canadian)Physicist12
32=Margaret Turnbull(American)Astrobiologist12
40=Elaine Pagels(American)Historian11
40=Enrique Ostrea(Philippino)Pediatrics & neonatology11
40=Gary Becker(American)Economist11
43=Mohammed Ali(American)Boxer10
43=Osama Bin Laden(Saudi)Islamicist10
43=Bill Gates(American)Businessman10
43=Philip Roth(American)Writer10
43=James West(American)Invented the foil electrical microphone10
43= Tuan Vo-Dinh(Vietnamese)Bio-Medical Scientist 10
49=Brian Wilson(American)Musician9
49=Stevie Wonder(American)Singer songwriter9
49=Vint Cerf(American)Computer scientist9
49=Henry Kissinger(American)Diplomat and politician9
49=Richard Branson(British)Publicist9
49=Pardis Sabeti(Iranian)Biological anthropologist9
49=Jon de Mol(Dutch)Television producer9
49=Meryl Streep (American)Actress9
49=Margaret Attwood(Canadian)Writer9
58=Placido Domingo(Spanish)Singer8
58=John Lasseter(American)Digital Animator8
58=Shunpei Yamazaki(Japanese)Computer scientist & physicist8
58=Jane Goodall(British)Ethologist & Anthropologist8
58=Kirti Narayan Chaudhuri(Indian)Historian8
58=John Goto(British)Photographer8
58=Paul McCartney(British)Musician8
58=Stephen King(American)Writer8
58=Leonard Cohen(American)Poet & musician8
67=Aretha Franklin(American)Musician7
67=David Bowie(British)Musician7
67=Emily Oster(American)Economist7
67=Steve Wozniak(American)Engineer and co-founder of Apple Computers7
67=Martin Cooper(American)Inventor of the cell phone7
72=George Lucas(American)Film maker6
72=Niles Rogers(American)Musician6
72=Hans Zimmer(German)Composer6
72=John Williams(American)Composer6
72=Annette Baier(New Zealander)Philosopher6
72=Dorothy Rowe(British)Psychologist6
72=Ivan Marchuk(Ukrainian)Artist & sculptor6
72= Robin Escovado(American)Composer6
72=Mark Dean(American)Inventor & computer scientist6
72=Rick Rubin (American)Musician & producer6
72=Stan Lee(American)Publisher6
83=David Warren(Australian)Engineer5
83=Jon Fosse(Norwegian)Writer & dramatist
83=Gjertrud Schnackenberg(American)Poet5
83=Graham Linehan(Irish)Writer & dramatist5
83=JK Rowling(British)Writer5
83= Ken Russell(British)Film maker5
83=Mikhail Timofeyevich Kalashnikov(Russian)Small arms designer5
83=Erich Jarvis(American)Neurobiologist5
91=. Chad Varah(British)Founder of Samaritans4
91=Nicolas Hayek(Swiss)Businessman and founder of Swatch4
91=Alastair Hannay(British)Philosopher4
94=Patricia Bath(American)Ophthalmologist
94=Thomas A. Jackson (American)Aerospace engineer 3
94=Dolly Parton(American)Singer 3
94=Morissey(British)Singer3
94=Michael Eavis(British)Organiser of Glastonbury 3
94=Ranulph Fiennes(British)Adventurer 3
100=. Quentin Tarantino(American) Filmmaker2


Extract from http://www.telegraph.co.uk/

Saturday, October 27, 2007

Hot topic in town - Facebook

Plan starting to develop a facebook application, not sure where to start and i found this wiki really help .... have a look .. Facebook for .Net developers ..
http://wiki.developers.facebook.com/index.php/ASP.NET

Thursday, October 25, 2007

System.Net.Mail.SmtpFailedRecipientsException

I'm migrating my existing application to a new application server. When test on the suggestion box which involve SMTP, i get below error message:



System.Net.Mail.SmtpFailedRecipientsException: Unable to send to all recipients. ---> System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: No such user here --- End of inner exception stack trace --- at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception) at System.Net.Mail.SmtpClient.Send(MailMessage message)

Few things that i test on new server:
  1. Install SMTP - check on document provided
  2. Testing with the Pickup directory
    You can also compose a simple e-mail text file based on the SMTP specifications (RFC 822). Here is the content of a sample text file typed in Notepad:

    From: myname@mydomain.com
    To: someone@somedomain.com
    Subject: testing
    This is the test message body.

    Simply copy or move the text file into the Pickup directory where SMTP was installed. (The default path should be "\Inetpub\mailroot\Pickup" but if you have Exchange installed then the path will be "\Program Files\Exchsrvr\Mailroot\Vsi 1\Pickup".)
  3. Set Relay Restrictions in the IIS admin. Put your app server IP Address/Domain Name in the Relay Resctictions.


  4. After all, remember to restart your machine. Restart IIS or Virtual SMTP server won't help. Restart the server do the best.

Done

CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

Facing an error below and found that i'm not alone.

Posted by Microsoft on 9/29/2005 at 4:46 PM
If you have used a Page that effectively uses a codebehind classname that is the same as say the Login control, that is Login, e.g. your page was called Login.aspx, then when you pre-compile (publish) the web site as an updateable web site, the aspx is retained and tries to compile against a type called Login in the code behind.


Server Error in '/' Application.
--------------------------------------------------------------------------------
Compilation Error


Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'


Source Error:

Line 118: public login_aspx() {

Line 119: string[] dependencies;
Line 120: ((Login)(this)).AppRelativeVirtualPath = "~/Login.aspx";
Line 121: if ((global::ASP.login_aspx.@__initialized == false)) {
Line 122: dependencies = new string[6];

Source File: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\3e0e0b67\701b7b2\App_Web_login.aspx.cdcab7d2.fhpe1ais.0.cs Line: 120






Many post and solutions can get from the internet. Among them is

  1. Rename Login.aspx to others name like signin.aspx
  2. Try using a classname for your codebehind and defined in the inherits that does not clash with a type in System.Web, e.g. LoginPage, or qualify the class and therefore the inherits statement with a namespace, e.g.<%@ page ... inherits="theNs.Login" %.namespace theNs { public partial class Login : System.Web.UI.Page { .. } }
  3. uncheck “Allow this precompiled site to be updatable” when Publish Web Site in Visual Studio 2005.
Solution no. 3 is good for me. Less work and works 100%.

Wednesday, October 24, 2007

A generic error occurred in GDI+.

Error Message received when try to upload picture to my web application:

Server Error in '/' Application.

A generic error occurred in GDI+.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.


Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +396978
System.Drawing.Image.Save(String filename, ImageFormat format) +69
Account.WarpImageDimensions(String filePath, String fileName, Bitmap imageToSave) +301
Account.ImageButton1_Click(Object sender, ImageClickEventArgs e) +350
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746



Solve this by:
1. check the permission for upload folder
2. check the correct upload path

problem solved.

Select top xx from DataTable

I was trying to figure out how to sort and select top 20 from a DataTable. Understand from the reading, DataTable have no "select top" feature. Some suggest use below method

DataTable outputTable = SourceTable.Clone();
for(int i=0;i<20;i++)
outputTable.ImportRow(SourceTable.Rows[i]);

In my case, i need to sort my DataTable oldTable and select top 20 after the sorting. I use DataView dView to sort it and copy it into a new DataTable newTable. For the display purpose, i use "for loop" to select top 20 from the new DataTable newTable.

Sample Code:

int maxDisplay = 20;
DataView dView = oldTable.DefaultView;
dView.Sort = " [Count] DESC ";
DataTable newTable = dView.ToTable();



int dCount = newTable.Rows.Count;
if (maxDisplay > dCount )
maxDisplay = dCount ;
if (dCount > 0)
{
for (int i = 0; i < maxDisplay ; i++)

{
xxxxxx;
xxx + newTable.Rows[i]["name"].ToString();

xxxxxx;
}
}

text wrapping in table : Firefox and IE

My case:
I'm using C# StringBuilder object to generate a long string with all blog Tags with link and without any white space between them. I've tried below code.


.hardbreak
{
width: 190px;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
<table style="TABLE-LAYOUT: fixed; WIDTH: 210px" cellpadding="'3'">

<tr>
<td class="hardbreak" style="WIDTH: 200px">

xxxx return StringBuilder code over here xxxx
</td>

</tr>
</table>

Result in IE: working fine. Even the word can be wrapped.



Result in Firefox: not working



this give me a problem.

I've try to google around and finally i found that i should insert a white space " " after every single tag before append to StringBuilder. Surprisingly, without using the class above, my problem solved.

Friday, October 19, 2007

Server Error in '/'Application. Configuration Error

Error Message on web.config when setting up a new application.

Server Error in '/'Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'requirePermission'.

Change the ASP.NET version to the correct version.



Problem solved.

Thursday, October 18, 2007

Must declare the scalar variable "@UserId".

We are doing server migration testing. I've restored a DB from production to staging server. I setup up a ASP.NET application and point to production server, everything work fine but when point to staging server, error below appear. By the way, we are using MS SQL 2005 standard edition in both server.

Server Error in '/' Application.

Must declare the scalar variable "@UserId".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@UserId".

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[SqlException (0x80131904): Must declare the scalar variable "@UserId".]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) +862234
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +739110
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +188
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +1956
System.Data.SqlClient.SqlDataReader.ConsumeMetaData() +31
System.Data.SqlClient.SqlDataReader.get_MetaData() +62
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +297
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +903
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +132
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +122
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) +62
Dal.GetRecentRater(Int32 PostId, DataTable dt) +190
Post.BindBlogPost() +1295
Post.Page_Load(Object sender, EventArgs e) +49
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061










At this point, i suspect something wrong with the staging server DB. So i access to the staging server and execute the stored procedure in Query Panel and it give me some error message.
Must declare the scalar variable "@UserId".







I open and check the stored procedure and the stored procedure is simple

ALTER PROCEDURE [dbo].[GetUserDetails]
@UserId int
as
select * from Users where UserId = @UserID


After check for a while, i change the @UserID to @UserId and magic happened. Problem solved. It's case sensitive.

It's strange because this stored procedure running in production server without any problem. Collation for both MS SQL 2005 DB are SQL_Latin1_General_CP1_CI_AS.

Tuesday, October 16, 2007

DataList Paging

There are always a problem to customize paging for DataList as below.

I'm able to develop a DataList Paging for my own application. Credit should give to Netomatix.
Please download and check the sample source code from my testing.
For testing purpose, i use Northwind database and i've created a new stored proc called: GetProductByCategory










Stored Procedure: GetProductByCategory

CREATE PROCEDURE [dbo].[GetProductByCategory]
@PageIndex INT,
@NumRows INT,
@Discontinued BIT = 1
AS
BEGIN
SET NOCOUNT ON
DECLARE @StartRowIndex INT;
SET @StartRowIndex = (@PageIndex * @NumRows) + 1;
WITH myProducts AS(
SELECT ProductID, ProductName, UnitPrice,
CategoryName, Description, UnitsInStock,
ROW_NUMBER() OVER(ORDER BY ProductID DESC) as Row,
count(*) over() AS ResultRowCount, Discontinued
FROM Products P
INNER JOIN Categories C
ON P.CategoryID = C.CategoryID
WHERE Discontinued = @Discontinued
)
SELECT * FROM myProducts
WHERE Row BETWEEN @StartRowIndex AND (@StartRowIndex + @NumRows)-1
ORDER BY ProductID ASC
SET NOCOUNT OFF
END

Monday, October 15, 2007

Could not load type '_Default'

Server Error in '/DataListPage' Application.

Parser Error

Description
: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type '_Default'.

Source Error:

Line 1: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" % >
Line 2:
Line 3: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
">

I'm able to run my application in Visual Studio, when try to open the application directly from IE, i get this error. After check for a while, i found that it's the problem for the ASP.NET Version that selected. After i change to ASP.NET 2.0.50727, problem solved.

ASP.NET wrapper for Twitter API

I was developing a ASP.NET wrapper for Twitter API and end up using the wrapper provided by Yedda. Credit should to Yedda.

Download the wrapper from Yedda. Unzip the files and you can play around with the project.

What i do is
  1. Create a new class name TwitterWrapper in my App_Code
  2. Copy the code from Twitter.cs and paste in TwitterWrapper.cs

to twitter your message:

string xmlOutput = "";
string TwitterUserName = "username";
string TwitterPassword = "password";

string TwitterMessage = "Hello twitter";

if (TwitterUserName != "" && TwitterPassword != "")
{
try
{
TwitterWrapper twitter = new TwitterWrapper();
xmlOutput = twitter.Update(TwitterUserName, TwitterPassword, TwitterMessage, TwitterWrapper.OutputFormatType.XML);
}
catch (Exception ex)
{ }
finally
{ }
}

Sunday, October 14, 2007

System.Web.HttpParseException: Could not load the assembly App_Web_xxxx. Make sure that it is compiled before accessing the page.

I always received error message from the web application after the last deployment.

System.Web.HttpParseException: Could not load the assembly 'App_Web_fsfkjwna'. Make sure that it is compiled before accessing the page. ---> System.Web.HttpParseException: Could not load the assembly 'App_Web_fsfkjwna'. Make sure that it is compiled before accessing the page. ---> System.Web.HttpParseException: Could not load the assembly 'App_Web_fsfkjwna'. Make sure that it is compiled before accessing the page. ---> System.Web.HttpException: Could not load the assembly 'App_Web_fsfkjwna'. Make sure that it is compiled before accessing the page.at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)at System.Web.UI.TemplateParser.ProcessInheritsAttribute(String baseTypeName, String codeFileBaseTypeName, String src, Assembly assembly)at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)--- End of inner exception stack trace ---at System.Web.UI.TemplateParser.ProcessException(Exception ex)at System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary parseData)at System.Web.UI.PageParser.PostProcessMainDirectiveAttributes(IDictionary parseData)at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective)at System.Web.UI.TemplateControlParser.ProcessMainDirective(IDictionary mainDirective)at System.Web.UI.PageParser.ProcessMainDirective(IDictionary mainDirective)at System.Web.UI.TemplateParser.ProcessDirective(String directiveName, IDictionary directive)at System.Web.UI.BaseTemplateParser.ProcessDirective(String directiveName, IDictionary directive)at System.Web.UI.TemplateControlParser.ProcessDirective(String directiveName, IDictionary directive)at System.Web.UI.PageParser.ProcessDirective(String directiveName, IDictionary directive)at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)--- End of inner exception stack trace ---at System.Web.UI.TemplateParser.ProcessException(Exception ex)at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding)at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)--- End of inner exception stack trace ---at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)at System.Web.UI.TemplateParser.ParseFile(String physicalPath, VirtualPath virtualPath)at System.Web.UI.TemplateParser.ParseInternal()at System.Web.UI.TemplateParser.Parse()at System.Web.Compilation.BaseTemplateBuildProvider.get_CodeCompilerType()at System.Web.Compilation.BuildProvider.GetCompilerTypeFromBuildProvider(BuildProvider buildProvider)at System.Web.Compilation.BuildProvidersCompiler.ProcessBuildProviders()at System.Web.Compilation.BuildProvidersCompiler.PerformBuild()at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath)at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)




After struggling for a while, i found that by doing 2 steps can solve this problem.




  1. Create a new Application Pool.

  2. Change the application pool for my application to the newly created pool.


Create new Application Pool in Internet Information Server 6 (Windows Server 2003)




  1. Open IIS 6


  2. Right click on Application Pools node from the tree view


  3. Select New -> Application Pool ... from the context menu


  4. Enter Application pool ID (myAppPool) and click OK.


  5. New Application Pool Created.



  6. Change the application pool for my application to the newly created pool.

  7. Open IIS
  8. From the explorer view, open the Web Sites folder.


  9. Point to the web application that want to change the Application Pool (mysite.com)


  10. Right click on mysite.com


  11. Select Properties


  12. A new Properties window pop up, Select "Home Directory" tab


  13. Change the Application Pool to "myAppPool" and click OK.


  14. Application Pool Changed


  15. Done.

    For Windows XP developer, when face this error, Kill aspnet_wp.exe process,

    go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files and delete all the temporary files. Try to compile your project again.


    Saturday, October 13, 2007

    remove "Yahoo Toolbar" from Firefox



    Open Mozilla Firefox,
    Go to Tools Menu, Click On Add-ons
    A new Add-ons windows popup, Select Yahoo Toolbar and click on Unistall button.
    Done

    ASP.NET Cookies

    Cookies is Domain dependent. Cookies created under subdomain beta.mydomain.com will not able to retrive when access to www.mydomain.com. To ensure that we can retrive the same cookies, we need to specify the domain
    For example, we want to write the information to cookies under mydomain when we access to url beta.mydomain.com

    HttpCookie cook = new HttpCookie("mydomain");
    Response.Cookies.Clear();
    Response.Cookies.Add(cook);
    cook["UserId"] = userId;
    cook["Name"] = username.Text;
    cook.Expires = DateTime.MaxValue;
    Response.Cookies.Add(cook);

    To retrive the cookies information:

    if (Request.Cookies["mydomain"] != null)
    {
    if (Request.Cookies["mydomain"]["UserId"] != null && Request.Cookies["mydomain"]["Name"] != null)
    {
    Session["UserId"] = Convert.ToInt32(Request.Cookies["mydomain"]["UserId"].ToString());
    Session["UserName"] = Request.Cookies["mydomain"]["Name"].ToString();
    }
    }

    Wednesday, October 10, 2007

    Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'

    I got error "Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress' "

    MailMessage msg = new MailMessage();
    msg.From = "info@xxx.com";
    msg.To = "comments@xx.com";
    msg.Bcc = "keith@xxx.com";

    msg.Subject = "Comment";
    msg.Body = "Comment: xxxxxxx xxxxxxx xxxxxxx ";
    SmtpClient smtpClient = new SmtpClient();
    smtpClient.Host = Global.smtp;

    To solve the issue, i change to below code

    MailMessage msg = new MailMessage();
    msg.From = new System.Net.Mail.MailAddress("info@xxx.com");
    msg.To.Add("comments@xx.com");
    msg.Bcc.Add("keith@xxx.com");

    msg.Subject = "Comment"; msg.Body = "Comment: xxxxxxx xxxxxxx xxxxxxx ";

    SmtpClient smtpClient = new SmtpClient();
    smtpClient.Host = Global.smtp;

    Tuesday, October 9, 2007

    Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of ..........

    When deploy a ASP.NET application to a new server, error message below shown:

    Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    invoice software

    Here is the scenario:
    My ASP.NET App use AJAX.NET and ASP.NET AJAX Control Toolkit
    My application server have NO AJAX.NET and ASP.NET AJAX Control Toolkit installed.





    To solve my problem with no AJAX.NET install in my application server:

    1. Copy AjaxControlToolkit.dll and AjaxControlToolkit.pdb version 1.0.61025.0 from my development machine to my ASP.NET App bin folder. (i install my AjaxControlToolkit in C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\AjaxControlToolkit)

    2. Copy System.Web.Extensions.dll (C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions) and System.Web.Extensions.Design.dll (C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions.Design) from my development machine to my ASP.NET App bin folder.
    Run the application and it's works.




    Alternatively, we can solve the problem by installing AJAX.NET and AjaxControlToolkit to the server.