Skip to main content

Posts

Showing posts from November, 2015

How to create cookies using c# asp.net

        /// <summary>         ///   This method is use to create cookies using c# asp.net.         /// </summary>         private static void CreatApp_Cookie( Session  session)         {             HttpCookie  httpCookie = HttpContext .Current.Request. Cookies [ "myCookie" ] ?? new HttpCookie ( "myCookie" );             httpCookie .Values[ "ID" ] = Convert .ToString(session.ID);             httpCookie .Values[ "Email" ] = session.Email;             httpCookie .Values[ "Name" ] = session.Name;             httpCookie .Expires = DateTime .Now.AddDays(365);             HttpContext .Current.Response. Cookies .Add(httpCookie);         }

Html.TextBoxFor readonly disabled Razor MVC5

How to set text box to readonly when usingHtml.TextBoxFor? Syntax for Readonly   @ Html.TextBoxFor(m => m.Email, new {@readonly = "readonly" }) Syntax for Disabled @ Html.TextBoxFor(m=> m.mobile, new {@disabled= "true" }) Example for Html TextBoxFor readonly and Disabled < div class ="form-group">     @ Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })     < div class ="col-md-10">         @ Html.TextBoxFor(m => m.Email, new { @class = "form-control" , @readonly = "true" })     </ div >     < div class ="col-md-10">         @ Html.TextBoxFor(m => m.mobile, new { @class = "form-control" , @readonly = "true" })     </ div > </ div >

Microsoft Visual Studio Code Is Open Source Now

In a developers event, Microsoft announced that Visual Studio Code open sourcing. The Visual Studio is a light weight code editor. The Visual Studio Code was initially released in this year. It's now available in beta version. Microsoft provided 60 extensions which are available now that includes better debugging, code linters etc. Build and debug modern Web and Cloud Applications. Code is free and available on your favourite platform - Linux, Mac OSX, and Windows. Visual Studio Code Beta version is available. Please click on below links to get new features and updates. https://code.visualstudio.com/ https://github.com/Microsoft/vscode https://code.visualstudio.com/updates https://code.visualstudio.com/Docs/supporting/howtoupdate

How to “Encrypt Decrypt” Connection String in “Web.config” Asp.Net C#?

In this post, I am going to share the “How to   encryption a connection string   of  “ web.config ”   file in ASP.Net MVC C#  using “ DataProtectionProvider ” data protection section as, ConfigSection.SectionInformation.ProtectSection( "DataProtectionConfigurationProvider" ); //Step 1: This below code is use to Encrypt connection string. namespace EncryptDecrypt_WebConfig { public class MvcApplication : System.Web.HttpApplication { protected void Application_Start () { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); //ENCRYPT DECRYPT WEB CONFIG SECTIONS. EncryptDecryptWebConfigSettings(); } /// <summary> /// ENCRYPT DECRYPT WEB CONFIG SECTIONS. /// </summary

Redirect http to https ASP.Net MVC

Hello everyone, I am going to share the code sample for redirect http to https ASP.Net MVC projects using the different types of techniques. The techniques types as given belows. Types 1: You can add the below code in Global.asax.cs for redirect http to https. protected void Application_BeginRequest( Object sender, EventArgs e) {     var httpRequest = HttpContext .Current.Request;     if (httpRequest.IsSecureConnection.Equals( false ) && httpRequest.IsLocal.Equals( false ))     {         Response.Redirect( " https ://" + Request.ServerVariables[ "HTTP_HOST" ] + httpRequest.RawUrl);     } } OR Types 2: You can add the below code in Global.asax.cs for redirect http to https. protected void Application_BeginRequest( Object sender, EventArgs e) {     switch (Request.Url.Scheme)     {         case "https" :             Response.AddHeader( "Strict-Transport-Security" , "max-age=300&q

Check null and empty string in ASP.Net C#

Hello everyone, I am going to share the code sample for check null and empty string in ASP.Net C#. String IsNullOrEmpty Syntax if (! string . IsNullOrEmpty (inputString)) {} else {} The code detail given below public bool ResetAccessFailedCount( string EmailId, int CountAttempt) {     bool IsSuccess = false ;     if (! string .IsNullOrEmpty(EmailId))     {         var user = base .Context.Tbl_Users.Where(e => e.UserEmail == EmailId).FirstOrDefault();         if (user != null )         {             user.FailedLoginAttempt = CountAttempt;             user.LastLogin = DateTime .Now;             Context.SaveChanges();             IsSuccess = true ;         }     }     return IsSuccess; }

Encryption and Decryption SHA1 hash string using ASP.Net C#

Hello everyone, I am going to share the code sample for decryption SHA1 hash password using ASP.Net C#.  The code details as given blow. public class HashSHA1Decryption {         /// <summary>         /// The SHA1 hash string is impossible to transform back to its original string.         /// </summary>         public static string HashSHA1 Decryption ( string value)         {             var shaSHA1 = System.Security.Cryptography. SHA1 .Create();             var inputEncodingBytes = Encoding .ASCII.GetBytes(value);             var hashString = shaSHA1.ComputeHash(inputEncodingBytes);             var stringBuilder = new StringBuilder ();             for ( var x = 0; x < hashString.Length; x++)             {                 stringBuilder.Append(hashString[x].ToString( "X2" ));             }             return stringBuilder.ToString();         }   } For more detail you can visit below links http:/

What's New in MongoDB 3.2?

" MongoDB is the fastest growing database because its provided more security protection mechanisms than others and also more reliable in cloud  computing environments. It is secure architecture for your deployment." There are some new thing is added in MongoDB 3.2. i.e. In MongoDB 3.2, some enhancements for real-time analytics, search and coupled. In MongoDB 3.2, some new pluggable  storage engines added. In MongoDB 3.2, It's more simplified data governance technique with document validation and coupled etc. In MongoDB 3.2, now some improvement operational efficiency  added for Enhanced management platforms. Continuous up-time across distributed. Multi-region deployments and zero-downtime upgrades.

angularjs difference between link and controller

Hello everyone, I am going to share the code sample for differentiate to link and controller . Link : The link is a function and use to attached handlers and also use for DOM  elements modification. Controller : The controller is use to share the $scope data within the scope and also provide the ways of linking the DOM elements. Table of Contents            HTML code sample for link vs. controller              AngularJs code sample for link vs. controller Full (HTML+ AngularJs) code sample for link vs. controller Live demo link   http://embed.plnkr.co/cbsRod/preview HTML code sample for link vs. controller < div ng-app ="linkApp">     < div ng-controller ="linkCtrl">         < link-directive ></ link-directive >     </ div > </ div > AngularJs code sample for link vs. controller var app = angular.module( 'linkApp' , []); //This is controller section. app.controller(