Monthly Archives: September 2012

Jquery – Cross domain script call – No transport error

I have spent few hours figuring out that why my below code is not working. This piece of code is beeing called from a asp.net website. It is calling a WebApi http service using jquery ajax api.

$(document).ready(function () {
$.ajax({
    url: "http://localhost:65209/api/values/SayHello",
    type: "GET",
    success: function (result) { alert(result);  },
    error:   function () { alert('error'); }
});

The reason was that using ajax I was trying to make a cross domain script call whiich by default will throw an error saying “No Transport”.
the solution is to introduce one line which was introduced after jquery 1.4.1 version onwards. Just add this line after $(document).ready() itself.

jQuery.support.cors = true;

That’s it! the same code works fine for me.

Note: Even though it works fine for you if you create your own service layer and website is trying to consume it. But there are few public websites  like netflix which does not allow cross domain scripting.

I hope it helps!

Advertisements

Intellitracing in Production environment – Tester meets Developer

Whenever a tester reports an exception in production, our Nosy 🙂 developers easily deny it saying that it works fine in his Dev environment. They can’t (actually donot want to) debug in production due to various reasons. Also, it is difficult to install any software to collect traces or record logs in Production environment. Hence MS came up with IntellitraceCollection standalone collector to record traces in production environment.

Intellitracing was introduced in VS 2010 ultimate edition. It is sort of historical debugging mechanism. It captures All Asp.Net, Ado.Net  events and Excpetion details like a recording.

This standalone collector is .cab file which will come with VS 2012 install itself. You can also download it separately.

Now with VS 2012 Intellitracing feature enables testers a way of recording their test case. Saving it as a .iTrace file and sharing it with Developer who can open it with VS2012 and replay the whole movie :).

Here are the steps we have to do it in Proudction environment. This is a one time setup. We should not keep it enabled always as .iTrace files grow in size very fast and your production server memory may be an issue. you can turn it ON and OFF as and when needed.

1. download intellitracecollctor.cab for VS 2012 RC. (Inellitrace collector)

2. With VS 2012 RC you will get it installed at this location “<VSInstallDirectory>\Common7\IDE\CommonExtensions\Microsoft\IntelliTrace\11.0.0”

3. Copy this .cab file to a some other location. Then Open powershell. goto location of .cab file. (PS> cd “location of .cab”)

4. type command ->  expand /f:* IntelliTraceCollection.cab . (mind this ‘.’ it will maintain the folder structure)

5. create one more folder where you record all your trace files. On this folder give your Apppool identity user full permissions to R/W.

6. Add windows feature “Windows Powershell Integrated Scripting Environment”. (You may want to restart not mandatory though).

7. powershell cmd type -> Import-Module <IntelliTraceExecutableDirectory>\Microsoft.VisualStudio.IntelliTrace.PowerShell.dll

Now Let us say we have a divide by zero exception in prod. Tester finds it and now want to record this experience as a .itrace file.

Tester may ask prod support(ASM) to start collecting trace files for sometime. remember you can start it and stop it. so lets enable recording of tester’s experience.

8. powershell type -> Start-IntelliTraceCollection <ApplicationPool> <PathToCollectionPlan.xml> <Path To Folder Where Saving trace>

9. it will confirm Yes/No input type Y press enter.

10.Now tester can go and replicate the issue. once the exception is thrown. Stop the recording.

11.To stop type ->  Stop-IntelliTraceCollection “DefaultAppPool”

12. Confirm with Y then press Enter.

13. Go to your log folder. See for the latest timestamp .itrace file.

14. copy it and share this .itrace file with Developer. It may be pretty big to attach to a bug so share the location.

15. Developer just needs to double click on it and VS2012 will be launched on his machine. This is how it looks once developer opens it.

.iTrace file opened with VS 2012

.iTrace file opened with VS 2012

16. you will notice Exception data section there. Just look for one of the last exceptions occured. In my example i have got a Divide by zero exception.

17. double click on that exception and BOOM!! your code is opened and exact line where the exception was thrown is highlighted. See screenshot

Code highlight

Code highlight

Note: If start command doesnt’ work. Try to import the dll first (point 7).

Now how cool is that? 🙂

I am still digging more into it and as soon as i find some more information i will update this post. 🙂

Update: You might be wondering how .iTrace files will the .pdb location.Actually it can be saved in Symbol Servers which are tracked by these .iTrace files and it opens those debug session from that location from any machine.

I hope it helps!