| Shreeman's profileShreemanBlogLists | Help |
|
March 22 Do you want to Debug ASP using VS2005:-Just Wait and Read thisMy friend called me and asked how can he Debug the ASP code ? I asked do you have vs2003 installed his reply was no but he has Vs2005 installed.However here i am writing my finding about both the scenario of debugging ASP code.
If you are trying to debug ASP code you might observer that your VS2005 debugger is not getting launched irrespective of the IE settinf of allowing Client Debugging.I googled myslef and found that there are some gotcha in debugging ASP code with VS2005 but unfortunatelty also there are more gotcha that is you can't enable( go project properties and set the debug option for both managed and unmanaged) both managed and unmanaged debugging at any single point of time.
While searched on web for this ,I found the explanation from Gregg here and its a nice post which provides why this is notdirectly supported and what you can do for debugging classic ASP code in VS2005.
Also don't forget to see this useful piece from IEblog if you wants more alternative:-
Debugging client Script is another one :-
Script Debugger is another imporatnat tool ( i initially was used to prefer it over VS):-
You still have problem:- GO and SEE the IE Setting and if you are looking for JAVA script then also theer are many JAVA script debugger although the above will work for most scenario in JAVA script too.
March 15 Are you using System.Transaction and Does it Get promoted to MSDTC WHEN it shouldn't???Are you using the new Transactional feature available with VS2005 namely the System.transaction??Not you are not using ??However you might opt for it once you know the feature provided thru it ..
I had a simply write up sometimes back on the usage of system.transaction here
However that post was mere an introduction into system.transaction and its capabilities.In short what System.Transaction provides you is An LTM(LIghtWeight Transaction Manager) and it will be auto upgraded to a MSDTC upon getting more RMs(ResourceManager).Not only this with the new TransactionScope you can wrap up the transactionscope Nicely.
The biggest wonder with System.transaction in WindowsVista timeframe would be the TRansactionalFileSystem without you to ship ur own CRM .You can read the msdnmag issue on the same subject line.
The system.transaction also provides you a commitable transaction which can span multiple threads.I had posted the post by Jim JhonSon on the same few days back.If you are looking for a link on this check JIM's Blog here
However not only this the system.transaction support for PSPE(promotablesinglephaseenlistment) with the LTM to MSDTC is probably the faster tracsaction.
Further in the same line you can see that it builts-in a view of providing the next generation of transaction thus you can perform the task creation of your own CRM or BYOT features in a non-legacy way(no com+ here).
For more on transaction you can check florin's blog here:-
Howvere my today's post is not related to the faetures associated with system.transaction but what i am going to discuss is if you are running a code usign system.transaction your obvious aim would be that to use the LTM based transaction feature so that you ll get promoted to the expensive MSDTC as less as possible.
Often due to a simple mistake and/or limitation with current transaction support while dealing with system.transaction you can ends up with MSDTC transaction:-
See the below code :-
if you are using something like the following or trying to reuse the connection you ll endsup with MSDTC:-
try
{ using (TransactionScope scope = new TransactionScope())
{ using (SqlConnection con = new SqlConnection("Data Source=SHREEMAN;Initial Catalog=test;Integrated Security=True")) { con.Open(); using(SqlCommand cmd1=new SqlCommand("update dbo.employee set lastname='Suyama5' where employeeid=6",con)) { cmd1.ExecuteNonQuery(); }
}
using(SqlConnection con1=new SqlConnection ("Data Source=SHREEMAN;Initial Catalog=test;Integrated Security=True")) { con1.Open(); using(SqlCommand cmd2=new SqlCommand("update dbo.employee set lastname='Suyama' where employeeid=6",con1)) { cmd2.ExecuteNonQuery(); } }
Thread.Sleep(5000); // use to see the transaction in dtc console scope.Complete(); } }
catch(TransactionAbortedException ex) { MessageBox.Show(ex.Message); } Now the workaround :-
The workaround is if you have multiple connection with same connectionstring(diff connection in most of the scenarios(although not always) ll ends up with multiple RM thus promoted to DTC anyway) pulls the conn and pass the same from the same local transaction and use it .
See Alazel's post on connectionscope on the same.
For a detail library also see John Doty's TransactionAdapter
More on different types of transactions and usage in future post
March 12 NotePad And Encoding : Did u saw any strange behavior???Here is a little exercise you can do to reproduce the behavior:- Just run Notepad.exe from the command prompt Now type abc.bak.abc.txt (That is space abc dot bak dot abc dot txt) without any space . Save the notepad and try to open it .You ll get some junk text ..Try to open it in IE or WordPad or Word you can see other text. Are you wondering with the behavior ..This is because of the different Encoding used by Notepad. For a detail description see here :- http://weblogs.asp.net/cumpsd/archive/2004/02/27/81098.aspx and see here for the explanation:- http://blogs.msdn.com/oldnewthing/archive/2004/03/24/95235.aspx March 09 sqldependency:Notification Self Updating Grid With DB ChnagesWhat I am going to post here is a simple beauty of the SqlServer2005 Notification.I am goign to display How can you have a Self Updated Grid when the DB changes.We ll levearage the SqlServer Notification and Little Bit of thread scenario to ceate a simpe app here :-
However before proceeding with the code parts be sure to read the limitation of query notification.That you need to have your query confor to the Indexed view requisite and also always check to see the necessary permission requirement .Liek you might need to enable brokerif its not,also you might need to set the permission for the notification.
Another important point is the notification seems to be happens in a different thrad and once notification happens the same wiped out .Further as a last point you need to also consider taht notification not only happens for row updates.
Finally the thread techniques i am using here is mere to get the thing work and the recommnedation here would be to read JUVAL LOWY at idesign and MSDN .Further giving few ref here for the notification.Hope that would help too.
SqlConnection con; SqlCommand cmd; DataTable dt; SqlDataReader dr; SqlDependency depend; private void Form1_Load(object sender, EventArgs e){ DataTable dt = new DataTable(); SqlDependency.Start("Data Source=SHREEMAN;Initial Catalog=test;Integrated Security=True");dt=configuredata(); dataGridView1.DataSource = dt; } private DataTable configuredata(){ using (con = new SqlConnection("Data Source=SHREEMAN;Initial Catalog=test;Integrated Security=True")){ con.Open(); using (cmd = new SqlCommand("select employeeid,lastname,city from dbo.employee", con)){ depend = new SqlDependency(cmd);depend.OnChange += new OnChangeEventHandler(MyOnChanged);dr = cmd.ExecuteReader( CommandBehavior.CloseConnection);dt = new DataTable();dt.Load(dr); dr.Close(); } return dt;} } delegate void sendmessage(DataTable msg); private void MyOnChanged(object sender, SqlNotificationEventArgs e){ sendmessage handler = new sendmessage(this.ShowMessage); DataTable dt = new DataTable();dt = configuredata(); Object[] args = { dt }; if (this.InvokeRequired){ this.BeginInvoke(handler, args);} } private void ShowMessage(DataTable dt){ dataGridView1.DataSource = dt; } private void button1_Click(object sender, EventArgs e){ DataTable dt = new DataTable();dt = configuredata(); } private void Form1_FormClosing(object sender, FormClosingEventArgs e){ SqlDependency.Stop("Data Source=SHREEMAN;Initial Catalog=test;Integrated Security=True");} Just Wait for my updates on the same using Web Scenario.
Recommended reading on the Sqldependency is on :- http://blogs.msdn.com/dataaccess/archive/2005/09/27/474447.aspx http://msdn2.microsoft.com/en-us/library/a52dhwx7.aspx http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/querynotification.asp
http://www.sqljunkies.com/WebLog/nielsb/archive/2004/09/21/4292.aspx http://www.thedatafarm.com/blog/PermaLink.aspx?guid=94659547-f5f7-44e9-ab57-1371d710d477 http://weblogs.asp.net/wallym/archive/2004/09/22/233120.aspx http://www.thedatafarm.com/blog/PermaLink.aspx?guid=68701804-b4fb-41a9-a06f-09a503c6aea0 http://www.codeproject.com/useritems/SqlDependencyPermissions.asp
threading :- http://www.idesign.net/idesign/uploads/Background%20with%201.1.zip http://www.microsoft.com/belux/nl/msdn/community/columns/himschoot/backgroundprocessing2.mspx http://blogs.msdn.com/brada/archive/2005/01/14/353132.aspx March 03 MIcrosoft's Anti XSS Library and 10 hacker tips for SQLserverMicrosoft has released an Anti CrossSiteScripting Library . you can downloadf the bits here :-
Also see this interestin and useful post on Ten hacker tricks to exploit SQL Server systems:
Path Resolution in ASP.NET Have a look into the VPPOne of the new features in Asp.Net 2.0 is the Virtualpath model which replace the Old Path resolution.The new Virtual path model is what gives the content to Asp.net .Thus you can its an end of the IO based path resolution.
So what does the VPP does is it servers you the web contents .
While lookinf for a scenario where i might ends up with httphandler to serve the requested path i was looking for alternatives and came to know this beautiful topic.Now to handle the IO based problem with your site no longer you had go for the httphandler and/or the absolute or relative path debate simply opt for VPP.
I am not going top provide a Demo code as there are quite a few already.See Below:-
http:\\www.scottgu.com
has also a demo on fileprovider(download the tips and tricks and scott has displayed how you can server the pages from Database.
|
|
|