Tuesday, 20 June 2017

Drop Down width increases automatically in IE 11

Add the onmousedown attribute and have it focus on the select dropdown so that it loses focus from the input box. For some reason focus on the input before accessing that select causes this error.
<select onmousedown="$(this).focus()">

Saturday, 3 June 2017

Cannot open database "" requested by the login. The login failed. Login failed for user 'IIS APPPOOL\'. after hosting on IIS

Looks like it's failing trying to open a connection to SQL Server.
You need to add a login to SQL Server for IIS APPPOOL\ASP.NET v4.0 and grant permissions to the database.
In SSMS, under the server, expand Security, then right click Logins and select "New Login...".
In the New Login dialog, enter the app pool as the login name and click "OK".
enter image description here


If you are using some custom app pool then give your app pool name.

Cannot open database "" requested by the login. The login fled. Login failed for user 'NT AUTHORITY\SYSTEM'. in mvc

Finally I set the pool identity on LocalSystem and thought why it might be preventing "NT AUTHRITY\SYSTEM" from opening a connection to my database. I opened up SQL Server Management Studio as the user "Administrator" and checked out the Server Roles for NT AUTHORITY\SYSTEM under "logins" section. The default server role for this user was public by default. I also checked sysadmin and refreshed my web application form.

Monday, 27 March 2017

Error: $injector:unpr Unknown Provider


This error results from the $injector being unable to resolve a required dependency. To fix this, make sure the dependency is defined and spelled correctly. For example:
angular.module('myApp', [])
.controller('MyController', ['myService', function (myService) {
  // Do something with myService
}]);

 The above code will fail with $injector:unpr if myService is not defined.

For More visit https://docs.angularjs.org/error/$injector/unpr

Friday, 3 February 2017

Route ' ' threw Exception System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

Route ' ' threw Exception System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.




Solution - 


Working with JSON within Web Services recently has become the latest and greatest simply because it plays so nicely with others and can often be very easily serialized and deserialized to fit your needs.
There is just something rewarding about having a massive collection of complex objects that can be throw into a simple string and passed across however you see fit and then completely regenerated in its original collection in just a handful of code.
However sometimes these strings can get big and I mean really big, like exceeding default values big and when this happens, exceptions happen. This post will cover a few ways that you can prevent a nasty InvalidOperationException that may look something like this with ease :

The Problem

You decide that paging data is for losers and decide to pull a graph of all of the data within your database, which will hypothetically contains thousands of complex objects, each with additional properties of their own. If your dataset is large enough, you’ll find yourself quickly exceeding the bounds that your Serializer can handle and you’ll be met with an exception and no data.

The Solution

There are three basic methods of handling this depending on your current environment :
  1. Setting the MaxJsonLength property default value within your web.config. (This will only apply to web-services that handle JSON)
  2. Setting the MaxJsonLength property of a JavascriptSerializer object to perform your serialization.
  3. If you are using MVC4 to handle returning your JSON values, you may want to override the default JsonResult() ActionResult and change the maximum size manually.
Either of these changes will help you avoid any bumps in the road when passing across your large JSON values.

Option I : The MaxJsonLength Property for handling JSON in Web Services

The MaxJsonLength property which can be set within the web.config of your application controls the maximum size of the JSON strings that are accepted by the JsonSerializer class. The default value is 102400 characters.
In order to increase the size of this value – you can just add the following code to your web.config file and set it to the value that you desire :
<configuration>  
   <system.web.extensions>
       <scripting>
           <webServices>
               <!-- Update this value to change the value to 
                    a larger value that can accommodate your JSON 
                    strings -->
               <jsonSerialization maxJsonLength="86753090" />
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration>  
It is important to know that this setting within the web.config will only apply to actual Web Services that handle your JSON strings using the internal JsonSerializer. If you are still encountering issues after applying this change, you will likely want to continue reading and consider using an instance of the JsonSerializer class to handle setting this value.

Option II : Using the JavaScriptSerializer and the MaxJsonLength Property to Handle Serializing JSON Values

Using an instance of a JavascriptSerializer will not actually inherit the previously defined within the web.config (as the web.config only applies to Web Services that handle the JSON) so you can easily just create an instance of the serializer and set the property accordingly :
// Creates an instance of your JavaScriptSerializer 
// and Setting the MaxJsonLength
var serializer = new JavaScriptSerializer() { MaxJsonLength = 86753090 };

// Perform your serialization
serializer.Serialize("Your JSON Contents");  
This will allow you to easily your larger data and adjust your maximum size easily.

Option III : Overiding the MVC4 JsonResult Action Result to Handle the Maximum Size

Much like the previously examples, every time that you are going to return a JsonResult you can simply add the MaxJsonLength property to a specific value depending on the context of your specific action :
return new JsonResult() {  
               Data = "Your Data", 
               MaxJsonLength = 86753090 
           };
or using the Json() method :
JsonResult result = Json("Your Data");  
result.MaxJsonLength = 8675309;  
However, if you want a more widespread solution that you could use within a single area of your application, you may want to consider overriding the JsonResult class and set your value within this newer class :
// This ActionResult will override the existing JsonResult 
// and will automatically set the maximum JSON length
protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding, JsonRequestBehavior behavior)  
{
    return new JsonResult()
    {
        Data = data,
        ContentType = contentType,
        ContentEncoding = contentEncoding,
        JsonRequestBehavior = behavior,
        MaxJsonLength = Int32.MaxValue // Use this value to set your maximum size for all of your Requests
    };
}

Wednesday, 18 January 2017

Friday, 6 January 2017

Severity Code Description Project File Line Suppression State Error Unable to resolve dependencies. 'Xamarin.Android.Support.Design 24.2.1' is not compatible with 'Xamarin.Forms 2.3.3.180 constraint: Xamarin.Android.Support.Design (= 23.3.0)'. 0

Xamarin Forms is not always compatible with the latest version of the Google Support libraries. Xamarin publishes them so Android developers (not using Forms) can utilize them if they need them, but Forms developers can continue to use the older, compatible versions.

Tuesday, 3 January 2017

Fluent NHibernate “Could not resolve property”

So this error comes when your n-hibernate query is not proper sql query.

For example

your query is
var riAlbum = session.QueryOver<Album>()
                .Where(x => x.Name == albumName && x.Artist.Name == artist)
                .List().FirstOrDefault();
this query will convert into sql as below
select
    Album.*
from
    Album
where
    Album.Name = 'SomeAlbumName' and
    Album.Artist.Name = 'SomeArtistName'
so that is wrong as last line 'Album.Artist.Name' is not proper sql. so u have to apply join in your n-hibernate query.

var riAlbum = 
    session.QueryOver<Album>()
               .Where(a => a.Name == albumName)
           .JoinQueryOver(a => a.Artist)
               .Where(ar => ar.Name == artistName)
           .List()
           .FirstOrDefault();