Wednesday, December 30, 2015

Started Personal Git Repository

I just pushed whatever i am learning for MVC5 on my personal Git repository-https://github.com/Nirav-Bhadradiya/learn.git
Below is the repository - anyone can point that and look at the stuff. I will be pushing more in next coming days.
Helpful for beginners.!!!! 

Setup Form Authentication in MVC 5

I was just trying Form authentication in MVC5 and i faced some problems while setting it up. i want to share it with you guys so you will not spend your precious time to find out solution.

Step 1: Add below tag in your project's web.config. Remember that you will see one web.config in View folder as well but that is for only View purpose.

<!--  attribute loginUrl is case sensitive please don't change it -->
    <authentication mode="Forms">
      <forms loginUrl="~/Authentication/Login"></forms>
    </authentication>

Here Login URL will be the View where you wanted to redirect your users when they tried accessing unauthorized Action methods.

Step 2; Add below attribute on your methods which you wanted to make secure. in this case i tried with my main action method of one of my Employee.cs class. You can make your whole controller secured with putting Authorize attribute for it.

[Authorize]
        public ActionResult Index()
        {
            var employeeListViewModel = new EmployeeListViewModel {UserName = User.Identity.Name};
            .................................................................
............................................................................
        }

Step 3: Now Modify your Login() Action to set cookies of loggedin user  FormsAuthentication.SetAuthCookie(u.UserName, false);

Step 4: Browse your Action method and it will take you to Login View.



Saturday, October 10, 2015

Fix The ‘Setup Couldn’t Start Properly’ Error When Downloading Windows 10

When you are trying to Upgrade windows 10 and in beetween if something gone wrong and it stopped then if next time you will try to start it it will show below error :

"Setup couldn't start properly.Please reboot your PC and try running windows 10 setup again."

media-creation-tool-error

To solve this issue follow below steps:

Step 1: Browse your drive where system is installed. usually (C drive)

Step 2: Make sure you can see hidden folders and files.

Step 3: Delete the folders named; $Windows.~BT and $Windows.~WS

Step 4: If when performing step 3 it gives any error that you can not delete this folder because it is used by some process then, download Unlocker from here : http://www.filehippo.com/download_unlocker/ 

Step 5: Run Windows Medic Creation Tool and it will again start from scratch.

Saturday, September 26, 2015

Pivot/Unpivot Columns in SQL Server

Today i just used Unpivot Functionality of SQL Server and i want to share with you guys.

What is Pivot and Unpivot ?

You can use the PIVOT and UNPIVOT relational operators to change a table-valued expression into another table. PIVOT rotates a table-valued expression by turning the unique values from one column in the expression into multiple columns in the output, and performs aggregations where they are required on any remaining column values that are wanted in the final output. UNPIVOT performs the opposite operation to PIVOT by rotating columns of a table-valued expression into column values.


Here is the simple fiddler for the same : http://sqlfiddle.com/#!3/e32bd/1