Some times we do have a requirement to call external web pages through our application.
The System.Net.HttpWebRequest Class allow us to make a call to any web page programmatically.
In the below code you will see how we can make a call to any webpage and get there response on our page.
if (!(IsPostBack))
{
try
{
System.Net.HttpWebRequest webReader;
Uri targetUri = new Uri("http://www.soliddotnet.com/index.php/contributors/neeraj-mathur");
webReader = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(targetUri);
//In the above code http://www.soliddotnet.com/index.php/contributors/neeraj-mathur/ is used as an example
//it can be a different domain with a different filename and extension
if ((webReader.GetResponse().ContentLength > 0))
{
System.IO.StreamReader strResponse = new System.IO.StreamReader(webReader.GetResponse().GetResponseStream());
Response.Write(strResponse.ReadToEnd());
if (strResponse != null) strResponse.Close();
}
}
catch (System.Net.WebException ex)
{
Response.Write("Page does not exist.");
}
}
NOTE: If you will try to access any web page from your localhost then this example wont work at all, you need to be on web domain to test this code
Now comes How to use HttpWebRequest to send POST request to another web server?
Typical example of this kind of situation is when you need to access some web resource through your application and that requires login credentials, So for this you can send post request to another server.
private void OnPostInfoClick(object sender, System.EventArgs e)
{
string strUserId = txtUserId.Text;
string strPassword = txtPassword.Text;
ASCIIEncoding encoding=new ASCIIEncoding();
string postData="userid="+strUserId;
postData += ("&password="+strPassword);
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://yourwebresource/MyIdentity/Default.aspx");
myRequest.Method = "POST";
myRequest.ContentType="application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
// Send the data.
newStream.Write(data,0,data.Length);
newStream.Close();
}
Resources :
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx
http://www.codeproject.com/KB/IP/httpwebrequest_response.aspx
VN:F [1.6.3_896]
Rating: 5.0/5 (1 vote cast)
Hello,
Just moving here and there in sql server 2008 looking for something new these days and found some information which may work for some…
when i am checking system database found importance of msdb database…this database contains lots of important information… like when user tried to take backup / restore of database with exact date and time…
right now i m posting small information will come with more details very soon ….
you can just check these four tables in your msdb details you will find all the relative information…
SELECT * FROM backupfile
SELECT * FROM backupset
SELECT * FROM restorefile
SELECT * FROM restorehistory
or you can run this query ….
SELECT backupfile.logical_name, restorehistory.user_name, backupfile.backup_set_id, restorehistory.restore_date, restorehistory.destination_database_name, restorefile.destination_phys_name, backupset.database_creation_date, backupset.backup_start_date, backupset.backup_size
FROM ((backupfile INNER JOIN backupset ON backupfile.backup_set_id = backupset.backup_set_id) INNER JOIN restorehistory ON backupfile.backup_set_id = restorehistory.backup_set_id) IN<code>NER JOIN restorefile ON restorehistory.restore_history_id = restorefile.restore_history_id
GROUP BY restorehistory.user_name, backupfile.backup_set_id, restorehistory.restore_date, restorehistory.destination_database_name, restorefile.destination_phys_name, backupset.database_creation_date, backupset.backup_start_date, backupset.backup_size, backupfile.logical_name;
if you need any thing in detail regarding the same please let me know will be more then happy to help you...
VN:F [1.6.3_896]
Rating: 5.0/5 (1 vote cast)
Hi , this post is all about discussing the latest new features being embedded , released up with SQL SERVER 2008 R2 CTP .
We are attaching the complete powerpoint presentation , that we had made to describe all the new features of this 2008 R2 CTP Release .
If you do have any kind of querries regarding the same , feel free to ping us back and we will be more than happy to solve your querries .
VN:F [1.6.3_896]
Rating: 5.0/5 (1 vote cast)
SQL Server uses an intelligent caching system to enhance performance. If you run
frequent queries against a certain table, SQL Server will recognize that fact and
store the source (and result data) of those queries in its internal cache. By doing
so, future matching queries won’t need to look up this data until the next time it changes.
This functionality, while useful, can be confusing if you conduct your tests by running your queries from SSMS — some of your query information may be cached, so your queries will run faster the second time you execute them.
To ensure that you make valid comparisons that don’t return cached information, clear your cache each time you run the query . The following script does just this — first it drops caches, then it calls a CHECKPOINT to flush pending changes from memory to disk, and finally it clears any data that has been stored in memory:
1
2
3
4
5
6
| DBCC FREESESSIONCACHE
DBCC FREEPROCCACHE
DBCC FREESYSTEMCACHE('ALL')
CHECKPOINT
DBCC DROPCLEANBUFFERS
GO -- Your query goes here |
VN:F [1.6.3_896]
Rating: 0.0/5 (0 votes cast)
Today when i am working with SQL Server 2008 and doing some RnD … find a new feature FILESTREAM … found really interesting and want to do some testing work…when i tried to enable the FILESTREAM in my SQL Server 2008 ( as bydefault it is not enabled) by running this T-SQL Command
EXEC sp_configure filestream_access_level, 2
GO
RECONFIGURE
GO
Command(s) completed successfully.
After that when tried to create a database.. it shows error “FILESTREAM feature is disabled.”
After lots of attempts finds the resolution of this problem…go to this url
http://blogs.msdn.com/sqlserverstorageengine/archive/2008/03/03/filestream-configuration-and-setup-changes-in-sql-server-2008-february-ctp.aspx
Download filestream_enable.vbs .. enter your machine name & Sql Server Instance Name and run this file…FILESTREAM will enable …
if you required this file pls let me know will provide you.
after that when i try to create Database with Filestream enable access successfully created that with following script
CREATE DATABASE TestFSDB
ON
PRIMARY (
NAME = TestFSDB,
FILENAME = 'D:\Tempdb\FS\TestFSDB.mdf'
), FILEGROUP TestFSDBFS CONTAINS FILESTREAM(
NAME = TestFSDBFS,
FILENAME = 'D:\Tempdb\FS\TestFSDBFS')
LOG ON (
NAME = TestFSDBLOG,
FILENAME = 'D:\Tempdb\FS\TestFSDBLOG.ldf')
GO
if you still face any problem please let me know will be more then happy to help you.
VN:F [1.6.3_896]
Rating: 0.0/5 (0 votes cast)