Domain Authority

Domain Authority is said created by Moz, great SEO tools (that I use too). Domain Authority is a score to the domain name.  It is basically the answer to “how trust worthy is this domain?”.

Refer to: https://moz.com/learn/seo/domain-authority

We score Domain Authority on a 100-point, logarithmic scale. Thus, it’s easier to grow your score from 20 to 30 than it would be to grow from 70 to 80.

Of course the higher is better.  So, how can you get higher domain authority? No one knows all things nor need to know all things, but I ll write what I know.

In the world of web pages, your web page is linked to other web pages, and that’s how Google and other real humans find you.  Google crawlers, wonder around in the world of web pages and see who and how you are connected to.  That’s Domain Authority.

And same goes for IP addresses.  You may have 100 references from 100 different domains, but one IP (server) address.  Then, you aren’t trust worthy as one with 100 unique IP addresses, in general.

And these links are not just one to one, you have to consider multi depth path to your site from the link.

So.. go get good links.  Yes, I know, You know, Everyone knows.  But, how to build and get good links? or should you even care about this..  I ll cover this more.

Conflicts between different versions of the same dependent assembly

Warning Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed.

Everyday I still (and ever will) encounter new error that I have never seen before.  And this is it today.

OK.. picking up keywords from the warning message, Assembly, different versions, conflict problems.  I wonder which which assemblies.

oh well let’s go to NuGet and make sure all things are updated.   I see Jquery and Newtonsoft.Json needing to be updated, and I did.

And fixed.

Input Validation from Model

If you want to improve user experience of your web services, you need to work on easy and friendly input interfaces for users through out.  Input validation being one of them, and validating user input for ASP.Net MVC is simple and intuitive.  You can use below at Model.

  • Required()
    • This makes specific field a required field.
  • MaxLength(max)
    • This specifies max length users can input for the field.
  • MinLength(min)
    • This specifies min length users can input for the field.
  • Range(min, max)
    • This specifies range of length (from min to max) users can input for the field.
  • RegularExpression(pattern)
    • This specified regular expression that users must match for the field.
  • EmailAddress()
    • The field must be email address. you can do same with RegulareExpression(pattern)
  • Url()
    • The field must be url.
  • Compare(other)
    • The field must match other.
  • CustomValidation(type,method)
    • This calls custom validation.

*The Model must make reference to System.ComponentModel and System.ComponentModel.DataAnnotations.

You can refer to http://www.asp.net/mvc/overview/getting-started/introduction/adding-validation too.

 

Global.asax

Global.asax is a global event handling file in App_Start folder.  This file is read first, and you can specify events and actions at app level.

When you save changes to an active Global.asax file, the ASP.NET page framework detects that the file has been changed. It completes all current requests for the application, sends the Application_OnEnd event to any listeners, and restarts the application domain. In effect, this reboots the application, closing all browser sessions and flushing all state information. When the next incoming request from a browser arrives, the ASP.NET page framework reparses and recompiles the Global.asax file and raises the Application_OnStart event.

https://msdn.microsoft.com/en-us/library/1xaas8a2(v=vs.71).aspx

 

Join (Include) two or more models

You have a model which defines book, and another model which defines author of the book.  How do you link them show in one table at the view?  Here is how.

suppose you have models define like below;

How to compose Linq that join these two together so it shows, Book ID, Title, Author Name?

The answer is, Use .include to include the model within.

 

Done.

Adding WebAPI to your current MVC Project

Started off as regular web site in MVC, later you want to add Web API to the same project?  You can simply add Web API controllers, but to make it work you have to do few more steps.

inside your Global.asax, you have to make reference to System.Web.Http and also add  GlobalConfiguration.Configure(WebApiConfig.Register)

This should take care of API request routing properly and good to go.

Iko puts it all well at http://stackoverflow.com/questions/26067296/how-to-add-web-api-to-an-existing-asp-net-mvc-5-web-application-project

Migration, Code First Database (EF)

When you are developing your web service, and working with your data set, often you need to make modification to your data set, and definition of your data set.  We can simply initialize (aka, delete and start clean) or migrate to continue on with data you have.

There are two types of migration Automatic Migration and C0de-Based Migration.  I am a lazy guy and I typically choose Automatic Migration, but I do come across situation where I have to run Code-Base migration, so I ll cover both here.

First you have to enable migration. Go to package manager console and run,

Then you should see something like;

Now you should see Migration folder being created, and we check Configuration.cs within that folder.  Then we will edit value for AutomaticMigrationEnabled to true to enable Automatic Migration.

Then we just run command below to let them automatically update whatever and however they want.

 

Next, I will cover the manual migration process.

You can also refer to ; https://msdn.microsoft.com/en-us/data/jj591621.

Working on Custom Domain Name with Azure

When you make web app on Azure, it comes with yourname.azurewebsites.net , and if it’s demo site or for internal use, that’s fine as is.  But most of the time when you want to run your own web services you want to have your own domain names, and that’s what I cover today.

Now you can buy domain name from Azure and that may be the easiest way to map custom domain to your web app.

But, I have already purchase domain elsewhere, and your company may already have domain name.  Then we will need to work with DNS record to point domain name to appropriate place within Azure. (DNS, as a function, uses data records table and map domain name to IP addresses.)

Each DNS server provide different ways to edit, create record, so I will skip that part.

DNS has several record types, but for now, we just worry about A and CNAME record types.

To set A record, you need IP address of your web app.  I somehow came across bug?? with new Azure management portal site and had to use old portal in order to get IP address, and here is how;

Use this URL: https://manage.windowsazure.com/

and continue to ignore new Azure Portal links, and move to Configure > domain names, then manage domains, there you should see the IP address for you to use for your A type record.

I don’t know if it’s my environment or bug at new Azure management portal, but I ll just go with whatever works, for sake of saving my time.

After setting A name for your root domain, www for your CNAME (or whatever you desire), wait for 5-10 minutes, then you should be good to go.

 

Using Facebook Login to Registger

Registration is VERY important part of function in all web services.  ASP.Net come with great and easy way to register and manage registered users accounts.  Yet, using third party authentication system like Facebook, Twitter, Microsoft, Google, Linkedin accounts can even make the registration process easier.

Facebook has about 1.5 billion monthly active users (http://newsroom.fb.com/company-info/) as of Sep 2015, what would be the reason to not use such popular web service’s authentication system.

When you create project in ASP.Net in Visual Studio, and choose “individual authentication”, you get a set of code there to easily implement Facebook login.   You can refer to this document on how to to turn on Facebook, Twitter, Microsoft, Google login integration. http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on.

The built in third party authentication logic is OK, but I want to make it better (for me), fetch profile information and put that into my own table.

Continue reading “Using Facebook Login to Registger”