Quite often, you need to see what a web site is sending from the ASP pages. You could use something like Ethereal but if you are a Firefox fan, an easy way is to use LiveHTTPHeaders.
You can get the LiveHTTPHeaders Firefox extension from here.
Then install it.
Click Firefox Tools / LiveHTTPHeaders.
If you want to limit the URL's that are monitored and you are a dab hand at regular expressions, then click Config tab / Filter URL's with regexp
Close the Config tab
From the Firefox menu, click Select View / Sidebar / LiveHTTPHeaders (or alternatively click Alt L)
Open a page from the website you wish to monitor. What is displayed is what is being sent to the server.
Enjoy!
Ideas and thoughts about Microsoft Identity, C# development, cabbages and kings and random flotsam on the incoming tide
Friday, June 01, 2007
Tuesday, May 01, 2007
ASP : Getting configuration variables from web.config
Instead of hard-coding these in the .cs code, you could use the following:
string inputFile = ConfigurationManager.AppSettings.Get("FileLoc");
In the web.config, in the appSettings section, enter something like:
LSBadd key="FileLoc" value="C:\somewhere\File.xml" /RSB
where:
LSB = Left square bracket
RSB = Right square bracket
You can also do this from Visual Studio when viewing an .aspx page. Click Website / ASP.NET configuration and type in the entries there.
Enjoy!
string inputFile = ConfigurationManager.AppSettings.Get("FileLoc");
In the web.config, in the appSettings section, enter something like:
LSBadd key="FileLoc" value="C:\somewhere\File.xml" /RSB
where:
LSB = Left square bracket
RSB = Right square bracket
You can also do this from Visual Studio when viewing an .aspx page. Click Website / ASP.NET configuration and type in the entries there.
Enjoy!
ASP : Creating Javascript on the server side
Javascript is normally created in the HTML file but it can be created on the server side.
e.g. the script to open another window could be:
where:
LSB = Left square bracket
RSB = Right square bracket
Enjoy!
e.g. the script to open another window could be:
string exampleScript =
"LSBscript language='javascript'RSB\n" +
"window.open ('http://some url', '_blank', " +
"'scrollbars=yes,resizable=yes,status=yes" +
",toolbar=no,menubar=yes,location=no" +
",width=screen.availWidth" +
",height=screen.availHeight" +
",screenX=0,screenY=0,top=0,left=0');\n" +
"LSB/scriptRSB";
ClientScript.RegisterStartupScript(typeof(Page), "ExampleScript", exampleScript);
where:
LSB = Left square bracket
RSB = Right square bracket
Enjoy!
C# : Creating dates
The simplest way is to use:
Enjoy!
string thisDate = "1990-01-01";
DateTime datetime = DateTime.Parse (thisDate);
Enjoy!
Friday, April 27, 2007
Recommended reading for developers
Thursday, April 19, 2007
ASP : Deploying web site from Visual Studio 5
From the ASP solution,
File / Add / New Project / Setup and Deployment / Web Setup Project
Type in a name and enter "OK".
The entry will now be in "Solution Explorer". Right-click and select "Add / Project Output". Ensure "Content Files" is selected and click "OK".
Now we want to build it. Right-click again and select build. This will create the .msi file in the directory.
Enjoy!
File / Add / New Project / Setup and Deployment / Web Setup Project
Type in a name and enter "OK".
The entry will now be in "Solution Explorer". Right-click and select "Add / Project Output". Ensure "Content Files" is selected and click "OK".
Now we want to build it. Right-click again and select build. This will create the .msi file in the directory.
Enjoy!
SOAP : Asynchronous web service
Had to implement an asynchronous web service which did not need to be real-time so no response was needed.
Had me a bit puzzled until I realised that a web service can return void!
i.e. in ASP:
[WebMethod]
public void webMethod(Some parameter)
compiles and runs no problem.
So what does it return?
The WSDL shows:
So it actually returns null!
Enjoy!
Had me a bit puzzled until I realised that a web service can return void!
i.e. in ASP:
[WebMethod]
public void webMethod(Some parameter)
compiles and runs no problem.
So what does it return?
The WSDL shows:
s:element name="webMethodResponse"
s:complexType /
/s:element
So it actually returns null!
Enjoy!
Wednesday, April 11, 2007
Windows : Getting a file list
Often need to put a list of files into a Word document or some such.
One way is to activate the command prompt (DOS box), navigate to the required directory and type:
dir /ON /B > dir.txt
The /ON option lists the files in alphabetic order. Further options are:
The /B option uses a bare format (i.e. no heading information or summary).
The pipe option (>) sends the results to a file called dir.txt in the current directory.
From here, it can be cut & pasted into the Word document.
BTW, if you ever need to get information about a DOS command, type:
help "command"
e.g. help dir
Enjoy!
One way is to activate the command prompt (DOS box), navigate to the required directory and type:
dir /ON /B > dir.txt
The /ON option lists the files in alphabetic order. Further options are:
/O List by files in sorted order.
sortorder N By name (alphabetic) S By size (smallest first)
E By extension (alphabetic) D By date/time (oldest first)
G Group directories first - Prefix to reverse order
The /B option uses a bare format (i.e. no heading information or summary).
The pipe option (>) sends the results to a file called dir.txt in the current directory.
From here, it can be cut & pasted into the Word document.
BTW, if you ever need to get information about a DOS command, type:
help "command"
e.g. help dir
Enjoy!
Unix : sum
Often transfer large files around using FTP or whatever e.g. ear and war files and it's useful to see if they were transferred without error.
sum is a useful utility to use for this.
It calculates and prints a 16-bit checksum for the named file and the number of 512-byte blocks in the file.
Enjoy!
sum is a useful utility to use for this.
It calculates and prints a 16-bit checksum for the named file and the number of 512-byte blocks in the file.
sum abcd.ear
05612 25680
Enjoy!
Monday, March 19, 2007
SOAP : WSCF - Web Services Contract First
"Contract first" involves creating the WSDL first and then using that to generate the code. There aren't many tools to do this.
Essentially, this approach involves modelling the messages, data and interfaces at the start and then publishing them as a contract before coding the implementation begins. Typically, modelling of the data and messages is done using a XML Schema (i.e. XSD files) and the contract is formalised using the Web Services Description Language (WSDL files).
thinktecture offer their free tool to do this which is nicely integrated with Visual Studio (2003 and 2005) and also allows a command line interface.
Get it from here.
Documentation and walk-through here.
Two MSDN articles which cover this are:
here and
here
Enjoy!
Essentially, this approach involves modelling the messages, data and interfaces at the start and then publishing them as a contract before coding the implementation begins. Typically, modelling of the data and messages is done using a XML Schema (i.e. XSD files) and the contract is formalised using the Web Services Description Language (WSDL files).
thinktecture offer their free tool to do this which is nicely integrated with Visual Studio (2003 and 2005) and also allows a command line interface.
Get it from here.
Documentation and walk-through here.
Two MSDN articles which cover this are:
here and
here
Enjoy!
Monday, February 26, 2007
C# : Predefining an array
The classic way of creating an array is:
but a more elegant way is:
Enjoy!
Document[] doc = new Document[2];
doc[0] = new Document();
doc[0].code = "ABC";
doc[1] = new Document();
doc[1].code = "DEF";
but a more elegant way is:
Document doc1 = new Document();
doc1.code = "ABC";
Document doc2 = new Document();
doc2.code = "DEF";
? = new Document[] {doc1, doc2};
Enjoy!
Subscribe to:
Posts (Atom)