Sunday, July 6, 2014

Tokens and Claims from AAD.

Tokens and Claims from AAD


AAD supports SAML 2.0 and JWT token formats and the claims supported by it are listed below.

Claims are added over time by AAD for supporting many other newer scenarios of federation, initially they are in preview and then brought to full support.























































Thursday, February 28, 2013

Testing made easy

PSR stands for “Problems Steps Recorder”.This is a utility that comes with Windows. 
I am sure this will save lot of time for Testers while reporting defects or sending information to others.  A quick and easy way to record a series of steps.

Advantages of PSR:
1) Not required to install as a separate tool. Comes with Windows OS.
2) Records and saves all the Steps and Screenshots as a MHTML file
3) Saves lot of time  (no longer required to take print screen of 100's of screens)
4) Saves lot of disk space

 
Follow the below steps to see how PSR works.
1)      In the “Run”, type in a command prompt as “psr”  (without the double quotes)
2)      A small dialog opens
3)     
Click on “Start Record” and perform the steps you would like to record.
4)      When finished, click on “Stop Record” and the tool will automatically prompt to save the recoding as a ZIP file
5)     
Save the ZIP file to a location (which will contain a mhtml file)
6)      Open the MHTML file and you will see all the steps you performed are recorded with “Detailed steps in plain English” as well as snapshot of each activity. 
 

Monday, February 25, 2013

Html Helpers and passing attributes on HTML tags the tricky ones

So this article is about the HTML helpers and the HTML they generate and how much control you have, now we all know how to write attributes on a HTML tag, but with HTML helpers how can we do it ??

1) Most Html helpers take HtmlAttributes object as a parameter, which is nothing but we pass in an anonymous object into the parameter and then the helper uses the "Property Name and Value" from the object as the attribute name and value on the html tag.

ex:


@using (Html.BeginForm("Search", "Home", FormMethod.Get,
new { target = "_blank" }))
{
<** input type="text" name="q" />
<** input type="submit" value="Search" />
}

would generate



Similarly, the second method is the overload in the Html helpers which takes an IDictionary which is also the same and use the dictionary keys as the attribute names and the object as the value.




new Dictionary<string, object>(){
                                                   { "key", "value" },
                                                   { "key1", someObj },
                                                   { "blah", 1 }
                                               } )


Both these approaches have some tricky bits, that is what I am writing this post for


For example, setting the class attribute of an element requires you to have a property named class on the anonymously typed object, or as a key in the dictionary
of values. Having a key value of “class” in the dictionary is not a problem, but it is problematic for
an object, because class is a reserved keyword in C# and is not available to use as a property name
or identifier, so you must prefix the word with an @ sign:

Ex:

@using (Html.BeginForm("Search", "Home", FormMethod.Get,
new { target = "_blank", @class="editForm" }))


Another problem is setting attributes with a dash in the name (like data-val). Dashes are not
valid in C# property names, but all HTML helpers convert an underscore in a property name to a
dash when rendering the HTML. 

Ex

@using (Html.BeginForm("Search", "Home", FormMethod.Get,
new { target = "_blank", @class="editForm", data_validatable=true }))

Produces the following HTML


method="get" target="_blank">





Small but sweet working of HTML Helper for BeginForm

Hello,

We all have written a lot of MVC applications code with form tags like this, please ignore the ** they are just for displaying html as text...


@using (Html.BeginForm("Search", "Home", FormMethod.Get)) {

<** input name="q" type="text" /**>

<** input type="submit" value="Search" /**>

}



This post I am just pointing a very small but nice thing that happens under the hood, the output from the above code would be something like

<** form action="/Home/Search" method="get" >

<**input name="q" type="text" /**>
<**input type="submit" value="Search" /**>
<** /form>


now we see the nice feature where we have a form opening and closing tag...so how does it get rendered by the helper underlying it uses a nice C# feature of disposing...so the main point is the Html.BeginFor returns an IDisposable which then has a dispose method which has a closing tag emitted in the dispose method so when implicitly dispose is called at the end of the using statement the closing tag is emitted. 

If not for this feature we would have ended up writing shit code like this for the same.


@{Html.BeginForm("Search", "Home", FormMethod.Get);}
<**input name="q" type="text" /**>
<**input type="submit" value="Search" /**>
@{Html.EndForm();}

Thursday, February 21, 2013

How do Strongly Typed Views work in MVC


Most of us know that in MVC we can have loosely coupled Views or

strongly typed Views but what difference does it make.

 

1)     Strongly typed views give us the benefit of intellisense, on the other hand intellisense is not available is loosely typed views.

 

2)     So how do we pass the data into a loosely typed view by using the Viewbag or ViewData, then what about strongly typed views ???? the big question is they look different but is there really a big difference other than it knowing the type for intellisense.

Ex:


public class HomeController : Controller
{
   public ActionResult Sample() {
        ViewBag.Message = "Hello World. Welcome to ASP.NET MVC!";
         return View("Sample");
}


}


And then access the content in the loosely typed view as shown below.

@{
  Layout = null;

}
 

 @ViewBag.Message

Now let’s see how it works in a strongly typed View, and you will for sure be like I did not know...just like I did. So this is how the Controller action would look:

public ActionResult List()
{

  var peanuts = new List();

     for (int i = 0; i < 10; i++)
    {
      peanuts.Add(new Nut {Title = "Peanut " + i } );
    }
   return View(peanuts);}


Now, let’s concentrate on the blue text in the code above, what is happening under the hood here is basically the same... View(peanuts) is assigning the value of peanuts to the ViewBag or ViewData… but that’s exactly what we do for loosely typed view.
 

 Yes, but only difference is we specifically assign to the Model property on the ViewData. ViewData is of type ViewDataDictionary which has a Model property [ So yes ViewData is not just a dictionary but a wrapper on top of it with some extra properties ], which is where the View(peanuts) actually assigns the value under the hood you can do this too as shown below

 ViewData.Model = peanuts;

Now, this is how code will look in your View to access the peanuts

@model IEnumerable
@foreach (Nut n in Model) {
 n.Title
}

 

 Model above is nothing but the property of Model from the ViewDataDictionary that is

implicitly referered to at runtime and now there is no missing link I guess now you know there basically is no difference in the strongly typed and loosely typed views except the intellisense.

 

 

 

I hope you did not know this, If you already did do not waste anymore time today...lol

 

Tuesday, February 19, 2013

Difference between using ViewData and ViewBag in MVC Views

For the most part, there isn’t a real technical advantage to choosing one syntax over the other. ViewBag is just syntactic sugar that some people prefer over the dictionary syntax




Although there might not be a technical advantage to choosing one format
over the other, there are some critical differences to be aware of between the
two syntaxes.

1) ViewBag works only when the key being accessed
is a valid C# identifier.
ex: if you place a value in ViewData["Key With Spaces"], you can’t access that value using ViewBag because the code won’t compile neither can you create an entry like that using ViewBag.

2)  Dynamic values cannot be passed in as parameters to extension methods. As the C# compiler must know the real type of every parameter at compile time in order for it to choose the correct extension method. If any parameter is dynamic, compilation will fail.
ex:  The below code will not compile.
    
     @Html.TextBox("name", ViewBag.Name)
To work around this,we can either use ViewData["Name"] or cast the value to a specific type:
    @Html.TextBox("name", (string)ViewBag.Name)



Monday, February 21, 2011

Overcoming the Workaholic Syndrome


Breaking up the Workday– Overcoming the Workaholic Syndrome

workaholicHi, my name’s Dan Wahlin and I’m a workaholic – I admit it.

Thursday, February 17, 2011

Common development tasks - Sending emails every day at a particular time

Was asked in a forum recently...



Automatic event fire in Asp.net? I want to fire an event in my asp.net application on specific time.

Monday, February 7, 2011

SQL Server Fundamentals of Data Storage

A very simple example about how SQL server stores data for a very basic table...very good example

Saturday, November 27, 2010

CSS Selectors


This is a small post of all the CSS selectors, so when you see a CSS file the next time you understand what the selector in the CSS file means.

Saturday, July 24, 2010

WCF fundamentals .

Understanding of why to use WCF and basic terminology used in WCF

Thursday, July 1, 2010

Fundamentals of Value Types and Reference Types

Fundamentals as to what is the meaning of val type and ref type when passed by value and passed by reference.

Tuesday, March 30, 2010

EXPRESSION TREES WHAT ARE THEY EXPRESSING

LINQ, have you hear the seen the keywords IEnumerable and IQueryable and do you know what the difference is ?

Wednesday, March 17, 2010

GARBAGE COLLECTION ON VALUE AND REFERENCE TYPES.



Garbage collection or memory manager in .net ...there is a very good video at the end...that is the best I have seen for understanding garbage collection..