16 February 2017

Different types of Action Results in MVC

In MVC controller may have one or more actions and can return different type of result like if you want to return Json, JavaScript, empty result, return view etc. ActionResults is the base class of all result type. ActionResults is abstract class. As ActionResults is the base class for all type of action results this means return type of ActionResults can be any of the below listed result types. In this topic we will learn how to use ViewResult, PartialViewResult, RedirectResult and JsonResult.

1.ViewResult (View): This return type is used to return a webpage from an action method.

2. PartialviewResult (Partialview): This return type is used to send a part of a 

    view which will be rendered in another view.

3. RedirectResult (Redirect): This return type is used to redirect to any other 


    controller and action method depending on the URL.

4. RedirectToRouteResult (RedirectToAction, RedirectToRoute): This return 


    type is used when we want to redirect to any other action method.

5. ContentResult (Content): This return type is used to return HTTP content 


    type like text/plain as the result of the action.

6. jsonResult (json): This return type is used when we want to return a JSON message.

7. javascriptResult (javascript): This return type is used to return JavaScript 


    code that will run in browser.

8. FileResult (File): This return type is used to send binary output in response.

9. EmptyResult: This return type is used to return nothing (void) in the result.



Advantages of MVC

1. One of the main advantage is that it will be easier to manage the complexity as the application is divided into model,view and controller.

2. It gives us the full control over the behavior of an application as it does not use view state or server-based forms.


3. It provides better support for test-driven development (TDD).


4. You can design the application with a rich routing infrastructure as it uses a Front Controller pattern that processes Web application requests through a single controller.



13 February 2017

16 December 2016

Create and Schedule a Job in SQL Server 2008

SQL Server agent can be used to create JOBS which can be scheduled to execute automatically. SQL Server Agent uses SQL Server to store job information. Jobs can have one or more job steps. Each step contains its own task.Each action in a job is a job step.We can schedule the job based on need as daily, weekly, monthly, hourly etc
For example, Let us create a job to back up a database automatically.
Steps to create Job in SQL Server Agent
1. Expand SQL Server Agent in Object Explorer.(If SQL Server Agent is stopped ,right click and start it)
image
2.Right click Job->New job.
image
3.Fill  the Name field with a  name for your job,Give description.
image
4. On the left side of the New Job window, you’ll see a Steps icon under the Select a page.Next add the individual steps for your job. Click the New button to create a new job step and you will see the New Job Step window.
image
  • Use the Step Name textbox to provide a name for the Step. select the database where the job has to be applied.
  • Use the Command textbox to give the Transact-SQL syntax corresponding to the desired action for this job step. Once you have completed entering the command, click the Parse button to verify the syntax.
  • Validate the syntax, click OK to create the step.
image
5.Schedule the job by clicking the Schedule icon in the Select a Page.Then schedule new job.
image
6.Create alerts for your job by Giving alert name and also select the database.Also select the type of alert and severity of your alert
image
7.Specify the actions to be performed when the job completes or when job fails.
image

8 December 2016

How to setup your Blog with GoDaddy

GoDaddy DNS service supports this feature so Let's show you how it's done:
For this demo, I assume you have an existing blog and you have already purchased a domain on GoDaddy.

Step 1: Go to the Settings Tab of your blog in the Blogger UI and click on the "Add a custom domain" link.


Step 2: Enter the URL you would like to use for your blog and press Save. I'm using "www.thisdemoblog.com" but the URL doesn't need to start with www such as "blog.mridey.com" where I published this article.


Step 3: You will get an error. It's expected as you have not configured GoDaddy with the DNS settings required. Now click on the "DNS settings file" link and save the file. Keep this window open, you'll need it later.


Step 4: In a new window, go to GoDaddy, login, go to the Domain Control Panel and click on your domain name.


Step 5: Click on the "DNS Zone File" tab.


Step 6: Click on the Edit button.


Step 7: We need to delete some of the existing records that GoDaddy adds by default. Select all the "A" records with "@" as host as well as the CNAME record "www" (if the URL you want to use starts with www) and press the Delete button.


Step 8: Press the "Save Zone File" button.


Step 9: Press Ok to confirm.


Step 10: Press Ok to confirm again. :)


Step 11: Now let's load the new records. Click the Import/Export button and select "Import".



Step 12: Click "Select File" and find the file you have saved in step 3, then click the "I understand ..." checkbox and press the Ok button.


Step 13: Press Ok to confirm.


Step 14: You should be able to see your new records loaded in GoDaddy. Four "A" records as well as two CNAME records. All good.


Step 15: Go back to the Blogger settings window we kept open in Step 3 and click "Save" again.


Step 16: If like me the GoDaddy DNS server processed the changes really quickly, it should all work fine and the settings should be accepted. You should be back to the main settings with your new custom domain accepted as the blog Address. So click on "Edit".


If Step 16 fails, be patient and retry later. It can take up to 48h for DNS settings to propagate. 

Step 17: Enable the "Redirect ..." checkbox and press Save. This is to allow "naked domain" redirect i.e. when users type your domain name without the www at the beginning.


Step 18: Finally click the "View blog" button at the top of Blogger UI, it should all work fine and your blog should now be enabled with a custom domain.