Posts

Showing posts with the label Troubleshooting

SVC handlers missing in IIS on Windows8

Image
A quick tip. I recently upgraded OS to windows 8 and installed both VS2010 and VS2012. Post that, my svc files stopped working in IIS and threw a 404 not found error. After a little struggle I found that .svc mappings were missing in IIS and the easy way to restore them is: 1. Open Control Panel 2. Select "Turn windows features on or off" 3. Expand.NET framework and check HttpActivation for WCF and you're done!

Pending AJAX terminating on window.location.href issue

Consider following 2 lines executed together: $.ajax('url',options) window.location.href= 'some url'; Many browsers (Chrome for example) terminate Ajax request when they encounter redirect call. Q. Why would I need ajax and redirect together? A. There can be many reasons. Most important being tracking scripts which does analytic on page visits. Q. Can't I solve that by making async as false for Ajax? A. Definitely Yes! $.ajax('url',{async:false}) would resolve the problem. But what if AJAX call is wrapped deep inside some third party plugin you're using where you've no control over ajax attributes? In this case you won't have the flexibility to apply async:false. To resolve this, you can make use of $.active property in JQuery. This property (damn useful) gives a count of number of open xmlHttpRequests on a page. So, coming back to our problem, you can do following to ensure plugin's ajax executes before redirect: SomPluginCalledHavingAja

JQuery unrecognized expression in parsing MVC Partial

This is a quick tip sharing. Recently, I was stuck in a problem where I was making an AJAX call to get MVC partial as HTML in response. Within this response, I made an attempt to find an element using $.find as following: $.ajax({ url: theURL, type: "POST", success: function (data) { var controls = $(data).find('#someTextBox'); } }); .find threw an exception: Uncaught Error: Syntax error, unrecognized expression: <HTML response> Issue was with enter keys and spaces in the response. Trimming data before calling find, resolved the issue. var controls = $(data.trim()).find('#someTextBox');

svn issue cannot display: file marked as binary type

Image
It is possible that you may face following issue while comparing different versions of a file - specially with .css and .js file as following: CAUSE:  It happens when SVN is not able to identify the mime-type for a file and sets it as application/octetstream FIX: To verify, select SVN properties of a any file under SVN repository. The popup shows the MIME-TYPE (if any). You can select MIME type and hit Remove button as shown below: However, if you have a lot of files, you can execute following batch command. It checks for all .css and .js files and set there mime-type to nothing. This worked great for me in a live project. It recursively iterates through all files from where the batch is executed, and deletes mime-type property for .js and .css file (if set). Later you would need to commit all the files for changes to take place so you've an option to view changes before updating server repository. echo off setlocal EnableDelayedExpansion FOR /R %%G in ("*.js") DO ( svn

Fixing ASP.NET application for IE10 compatibility

We've a stable MVC web application. However, recently there was a sprung in issues (mostly JavaScript) breaking many of the existing features. Recently, QA started to test application in IE10 browser after the analytic showing an increased traffic from it (Thanks to a lot of new Windows 8 devices). Where QA was quick enough to log defects one-after-the-another , we as a developer, were a bit panicked. This post is all about fixing your application for IE 10. I'm in progress of fixing my application and will keep posting any new gimmick. (I appreciate if you could share your experiences too) 1st Fix (Master Stroke) Issue: Application working in cookieless mode. I.e. Adding session to URL. For example: upon login (Forms Authentication), http://mysite.com/welcome.aspx, it shows http://mysite.com/welcome.aspx(A(ikRoEoqwOieH_FyADedeEbit-_uDNadHNudahUar-HaUsU99DiasIadsjKAsjJiaojdJaJadijAQBR0))/Welcome.aspx The first fix I did, was with minutest change but fixed more than 80% issues i

Error while enabling windows feature NetFx3

Image
Recently, I tried to install SQL 2012 express edition on a Windows 8 OS running inside VMware. Installation wizard is very much the same as SQL 2008, so I thought it's going to be pretty smooth. With several Next  clicks, my installation process started. BUT :( it got aborted with following error: The following error has occurred: Error while enabling windows feature : NetFx3, Error Code : -2146498298. Reason: ========================================================= Installation process requires .NET framework 3.5, which is generally not installed along with windows. However, it is available in Turn Windows Features On/Off option. Most likely this will be unchecked if you are getting NetFx3 installation error. You'd be tempted to quickly check and try install this component. It shows 2 options - Install from a disc or install from internet. If you try later option, it will fail (I don't know reason but you'd see a generic error message). Check following resolution for

Conditionally render MVC layout section

Error: The following sections have been defined but have not been rendered for the layout page "~/_SiteLayout.cshtml" Reason: Let's say there is a Layout as following: <html> <head> </head> <body> @RenderBody() @RenderSection("footer") </body> </html> And a view as following: <H1>Hello World</H1> @section footer{ Copyright 2012 } When rendered, <h1>Hello World</h1> will be rendered by RenderBody() while Copyright 2012 will be rendered by RenderSection(). But, what if for some reason you want to display footer conditionally on Layout? So for that, if you do something like following, you will encounter an error: <body> @RenderBody() if(condition){ @RenderSection("footer") } </body> Reason is that MVC needs to flush out section declared in your view. Else it displays error as on top of article. To resolve this, there is a quick trick: <body> @RenderBody() if(condition

Keyset does not exist issue in creating VS STS project

Error: Keyset does not exist When: While creating Visual Studio ASP.NET STS Website (a project type for WIF) Impacts: Causes FederationMetadata.xml to be empty Reaon(s): STSTestCert certificate might be corrupt/lost or not accessible. Resolution: 1. Click Start, type mmc in the Search programs and files box, and then press ENTER.  2. On the File menu, click Add/Remove Snap-in.  3. Under Available snap-ins, double-click Certificates.  4. Select Computer account, and then click Next.  5. Click Local computer, and then click Finish. Click OK.  6. Under Console Root, Certificates (Local Computer), in the Personal store, click Certificates.  7. Select STSTestCert certificate and right click 8. From context menu select All task > Manage Private Keys 9. Most likely, you would see "Object Not found" error. If so, delete this certificate and close console. Note: 1. If you can not see STSTestCert, this post might not be useful to you OR alternatively, you can try steps 7-9 for all o

The following module was built either with optimizations enabled or without debug information Visual Studio

Image
If you are facing this issue for long you must be on verge of banging your head or throw away your PC. There are many cause for this error. You might have tried options and may have missed a few. Following is a summary of different things that have helped me in resolving this issue (Hope it helps you out too): 1. In your Visual Studio, Go to Tools>Options>Debugging>General and check "Enable just my code as shown below" 2. If your application is configured to run using a IIS URL instead of dynamic localhost port, just ensure that IIS directory is pointing to your directory. Often while testing we make different copies of application and keep pointing application in IIS to one or the other. This actually resolved my issue. 3. Clean your solution, close VS, open again, rebuild application and try 4.Open properties of your project and ensure configuration as below: 5. Continuing from above, press advance button in Build settings below which opens a popup. Ensure, Debug I

Connect with 32bit DSN from 64bit .NET

Recently I ran into a trouble. I was using a specific database which supported only 32bit ODBC connections. However my machine was 64bit Win7. If I connected to my 32bit DSN from Excel, I could get the data but from Visual Studio I received error :" There is an architectural mismatch". The reason was that by default my .NET communicated with 64bit driver. To force it to use, I changed my project Platform target from "ANY CPU" to "x86".. and it worked!! :)

Accesssing TextBox value in Init Event

As per ASP.net Page Lifecycle, Events that actually wire up Server Controls and load their viewstate, take place, quite after Init. However, one thing to remember is that even in Init Request object is available. Hence, if you are aware of textbox control then you can access it using Request["textBoxName"]. Ideally you would use HTMLcontrol instead of ASP.net server control Like: <input type="text" id="myTextbox" value="<%=SomeValueFromServerSide%>"> This textbox then can easily be accessed in Init using var textBoxValue = Request["myTextBox"]

Dropdown value when EnableViewstate = false

If EnableViewstate of a dropdown is set to false, you would need to bind the data at every post. Nothing new in this! But, you might face issues in retrieving value selected in dropdown before postback. It will always be "" To get the value, pre-populate dropdown in Page_Init instead of Page_Load (if you are doing so). This will give the right selected value.