MVC CORS works in IE but not in Chrome - asp.net-mvc

I'm stuck with a CORS issue which works totally fine when I'm using Internet Explorer, but doesn't work with Google Chrome.
I have 2 separate projects in Visual Studio 2013: PROJECT 1 is on port 1044, it's just an empty project containing an HTML page with a Button which uses AngularJS to make a call to ACTION GetCustomer residing inside PROJECT 2 on port 1042. The ACTION then returns JSON data back to PROJECT 1.
The cross domain call works fine when the Button is clicked in IE and returns the data back to the HTML TextBox saying "ShivDataFromServer". But the same doesn't happen in Chrome.
PROJECT 1 on port 1044:
HomePage.html:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<script src="angular.min.js"></script>
<!--<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>-->
<body>
<script type="text/javascript" src="CustomerViewModel.js"></script>
<div ng-app>
<!-- Below is our VIEW i.e. Display-->
<div id="ViewCustomer" ng-controller="MyController">
Customer Name: <input type="text" id="txtCustomerName" ng-model="Customer.Name" /> <br />
Customer Amount: <input type="text" id="txtCustomerAmount" ng-model="Customer.Amount" /> <br />
<div style="width : 242px; height : 26px; background-color : {{CustomerView.Color}}"></div> <br />
<input type="button" id="btn1" value="Get data from Server" ng-click="GetData()" />
</div>
</div>
</body>
</html>
CustomerViewModel.js:
function MyController($scope, $http) {
$scope.Customer = { "Name": "ShivHardCodedData", "Amount": "1000" };
$scope.CustomerView = { "Color": "" };
//BELOW IS TRANSFORMATION LOGIC! Depending on Amount it will be GREEN or RED meaning "danger".
$scope.$watch("Customer.Amount", function() {
if ($scope.Customer.Amount < 1000) {
$scope.CustomerView.Color = "Green";
} else {
$scope.CustomerView.Color = "Red";
}
}
);
$scope.GetData = function () {
//BELOW WORKS!!
$http({ method: "GET", url: "http://localhost:1042/Customer/GetCustomer" })
.success(function (data, status, headers, config) { $scope.Customer = data; })
.error(function (data, status, headers, config) { });
} //END OF "GetData() function"
}
PROJECT 2 which is an MVC project on port 1042:
CustomerController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using P10JsonJQuery_httpService.Models;
namespace P10JsonJQuery_httpService.Controllers
{
public class CustomerController : Controller
{
[ImAllowingCors]
public ActionResult GetCustomer()
{
Customer objCustomer=new Customer();
objCustomer.Name = "ShivDataFromServer";
objCustomer.Amount = 1000;
return Json(objCustomer, JsonRequestBehavior.AllowGet);
}
}
//CORS (Cross Origin Resource Sharing). I've made up name "ImAllowingCors" but ending "Attribute" is C# KEYWORD
public class ImAllowingCorsAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//This means ALLOW any calls from a Cross-domain (i.e. allow calls from different server)
filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*");
base.OnActionExecuting(filterContext);
}
}
}

ie does not count calls on different ports, but the same domain as being cross origin, whereas Chrome does. Thus, you need to set it up for chrome to allow this.
To do it the way you are trying, you will need to make sure the custom filter is registered and I think you will also need to change your attribute to [ImAllowingCorsAttribute]:
See: similar issue
You will need to allow Cors for your app. Something like the following annotation above the action:
[EnableCors(origins: "http://localhost:1042", headers: "*", methods: "*")]
Perhaps put a breakpoint in your attribute, as I doubt it is being hit. This should show you how to enable cors:
enabling Cors

Related

$.get() and $.post() in MVC app works fine in local Cassini webserver but when published into IIS 7.5 it doesn't work anymore

I'm actually stuck on this MVC application and can't find out the cause.
The code works fine in local Vis Studio 2013 Cassini webserver.
Hence when I type the URL in the browser: "/Customer/EnterCustomerDetails"
then I'm displayed a simple form, a DIV tag containing status message "Loading..." and after 5 seconds some data via EF is returned due to the $.get() script that gets executed.
However, when I publish the same code into IIS 7.5 running inside Windows 7 Ultimate, then all I see is the form and only the div tag that displays the message "Loading..." but no data is displayed and it seems the $.get() is not working in the full blown IIS and neither is $.post().
Where am I going wrong? Any help much appreciated. Thanks in advance.
"EnterCustomerDetails.cshtml"
#model P10LearnNewMVCWithEF.ViewModel.CustomerViewModel
#using P10LearnNewMVCWithEF.Models
#{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>EnterCustomerDetails</title>
#*BELOW Weve IMPORTED the 3 important JQuery LIBRARIES, since we want to use the $.get() AJAX method*#
<script src="~/Scripts/jquery-1.8.3.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
</head>
<body>
<div>
<form id="frm1">
Customer Code:- #Html.TextBoxFor(m => m.Customer.CustomerCode)
#Html.ValidationMessageFor(x => x.Customer.CustomerCode) <br />
Customer Name:- #Html.TextBoxFor(m => m.Customer.CustomerName)
#Html.ValidationMessageFor(x => x.Customer.CustomerName) <br />
<input type="button" value="Submit via true AJAX" id="btn1" onclick="SendData()" />
</form>
<div id="status"></div>
<table id="tbl">
<tr><th>Customer Code</th><th>Customer Name</th></tr>
</table>
<script type="text/javascript">
$("#status").text("Loading..."); //Add STATUS MESSAGE "Loading..." to DIV. Must use ".text" and NOT ".val"
//Making a CALL to the "GetCustomers" ACTION within the "Customer" CONTROLLER and Results returned will be in "BindData"
$.get("GetCustomers", null, BindData);
// The "GetCustomers" ACTION will return the JSON data into this JavaScript function
function BindData(customers) {
var tbl = $("#tbl");
for (var i = 0; i < customers.length; i++) {
var newRow = "<tr>" +
"<td>" + customers[i].CustomerCode + "</td>" +
"<td>" + customers[i].CustomerName + "</td>" +
"</tr>";
tbl.append(newRow);
}
$("#status").text(""); //REMOVING STATUS MESSAGE to EMPTY
}
function SendData() {
$("#status").text("Adding data via ajax..."); //Add STATUS MESSAGE "Loading..." to DIV. Must use ".text" and NOT ".val"
var frm = $("#frm1").serialize();
$.post("Submit", frm, BindData);
$("#Customer_CustomerCode").val("");
$("#Customer_CustomerName").val("");
}
</script>
</div>
</body>
</html>
"CustomerController.cs"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.Mvc;
using P10LearnNewMVCWithEF.DAL; //"CustomerDal" in here which derives from "DbContext"
using P10LearnNewMVCWithEF.Models; //"Customer" class in here
using P10LearnNewMVCWithEF.ViewModel;
namespace P10LearnNewMVCWithEF.Controllers
{
public class CustomerController : Controller
{
//Below is our NEW Simplified ACTION that will simply display our Enter Customer Details UI
public ActionResult EnterCustomerDetails()
{
CustomerViewModel objCustomerViewModel = new CustomerViewModel();
objCustomerViewModel.Customer = new Customer(); //This code by SHIV is pretty useless
//NOTE - WE'RE NOT RETRIEVING ANY DATA FROM DATABASE ANYMORE! as we'll do that with "GetCustomers()" ACTION
return View("EnterCustomerDetails", objCustomerViewModel);
}
public ActionResult Submit()
{
Customer obj = new Customer();
obj.CustomerCode = Request.Form["Customer.CustomerCode"]; //"name" is used on Server-side. "id" is used in Client-side.
obj.CustomerName = Request.Form["Customer.CustomerName"];
CustomerDal dal = new CustomerDal();
if (ModelState.IsValid)
{
//Let's INSERT the new Customer into DB via EF
dal.Customers.Add(obj);
dal.SaveChanges();
}
List<Customer> customersColl = dal.Customers.ToList<Customer>(); //Return all data from tCustomer via EF
return Json(customersColl, JsonRequestBehavior.AllowGet); //make sure you say customersColl AND NOT “customersColl”
}
//Below: "GetCustomers()" ACTION will be called by $.get() and simply returns a Collection of JSON data
public ActionResult GetCustomers()
{
CustomerDal dal = new CustomerDal();
List<Customer> customerscoll = dal.Customers.ToList<Customer>();
Thread.Sleep(5000);
return Json(customerscoll, JsonRequestBehavior.AllowGet);
}
}
}
Posting this as an answer so that you can mark it as answered.
That sounds like the identity in your IIS app pool is not authorized for database access. Either assign a new identity that has permission, or grant access to the identity you are using.

AngularJS routing Issues $injector:modulerr

Ok so I am fairly new at AngularJS and just running through a demo, but I am having issues with the routing side of things and can't figure it out. I thought you guys would know instantly that I have done something dumb.
So here goes.
This is my JS file
var WebApplication2 = angular.module('WebApplication2', ['ng-route']);
WebApplication2.controller('LandingPageController', LandingPageController);
WebApplication2.config([
'$routeProvider',
function ($routeProvider) {
$routeProvider
.when('/routeOne', {
templateUrl: 'routesDemo/one'
})
.when('/routeTwo', {
templateUrl: 'routesDemo/two'
})
.when('/routeThree', {
templateUrl: 'routesDemo/three'
});
}
]);
And here is my html code
<html ng-app="WebApplication2" ng-controller="LandingPageController">
<head>
<title ng-bind="models.helloAngular"></title>
</head>
<body>
<h1>{{models.helloAngular}}</h1>
<ul>
<li>Route One</li>
<li>Route Two</li>
<li>Route Three</li>
</ul>
<div ng-view></div>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/angular-route.min.js"></script>
#Scripts.Render("~/bundles/AngularBundle")
</body>
</html>
I also have this js controller file
var LandingPageController = function ($scope) {
$scope.models = {
helloAngular: 'I work!'
};
}
I then have a controller with the following actionresults
public class RoutesDemoController : Controller
{
public ActionResult One()
{
return View();
}
public ActionResult Two()
{
return View();
}
public ActionResult Three()
{
return View();
}
}
This is a dependency injection error.
Try this :
var WebApplication2 = angular.module('WebApplication2', ['ngRoute']);
instead of :
var WebApplication2 = angular.module('WebApplication2', ['ng-route']);
Since you are using routing, you should not declare an ng-controller attribute on your view. With routing, each of your views can use a different controller.
Instead of the HTML tag you mentioned above, it should be like this:
<html ng-app="WebApplication2">
You should declare the controller you wish to use in your route. The templateUrl is the path to the HTML file you will use as the template:
$routeProvider.when('/routeOne', {
templateUrl: 'views/route-one.html',
controller: 'LandingPageController'
})
Your controller's code should look something like this:
WebApplication2.controller('LandingPageController', function ($scope) {
$scope.models = {
helloAngular: 'I work!'
};
});
Where you are using <h1>{{models.helloAngular}}</h1> that is not in the scope of your route. The views for your routes will render in <div ng-view></div>.
In your views/route-one.html file you can add <h1>{{models.helloAngular}}</h1>.
You can view this page in the docs for an example implementation of ngRoute.
Angular is used to build single-page applications—your ASP.net's router will have nothing to do with Angular's routes. You just need to declare a single static route that is pointed to your Angular application. Server-side and client-side routing will not work hand-in-hand.

Why can't I HtmlDecode in ASP.NET MVC 3

Here is the scenario. I want to use CKEditor for a rich text field on a form, but for whatever reason I cannot get the contents from the textarea to the server and back to the page without encoding problems. Here is the little sample program I wrote up to try and figure out what is going on. First, my view model:
HomeViewModel.cs
namespace CkEditorTest.Models
{
public class HomeViewModel
{
[Required]
[DataType(DataType.Html)]
[Display(Name = "Note")]
public string Note { get; set; }
}
}
Now my controller:
HomeController.cs
using System.Web.Mvc;
using CkEditorTest.Models;
namespace CkEditorTest.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View(new HomeViewModel());
}
[HttpPost]
[ValidateInput(false)]
public ActionResult Index(HomeViewModel model)
{
return View(model);
}
}
}
And finally, my view:
Index.cshtml
#model CkEditorTest.Models.HomeViewModel
#{
ViewBag.Title = "CKEditor Test";
}
#section head
{
<script type="text/javascript" src="#Url.Content("~/Scripts/ckeditor/ckeditor.js")"></script>
<script type="text/javascript" src="#Url.Content("~/Scripts/ckeditor/adapters/jquery.js")"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#Note").ckeditor();
});
</script>
}
<h2>CKEditor Test</h2>
#using (Html.BeginForm())
{
#Html.LabelFor(m => m.Note)<br /><br />
#Html.TextAreaFor(m => m.Note)<br />
<input type="submit" />
}
#if (!String.IsNullOrEmpty(Model.Note))
{
<div id="noteText">#Model.Note</div>
}
No matter what I do, I cannot display the Model.Note property as html on my view. By the time it reaches the view it is HTML encoded (i.e. <p> etc...). Here is what the form looks like pre-post:
pre-post http://www.matthewkimber.com/images/so/pre-post.png
And here is what the result is in the div below the "Submit" button:
post result http://www.matthewkimber.com/images/so/posted.png
I've set a breakpoint within Visual Studio and it shows as bare angle brackets (no encoding on HTML elements, just characters).
breakpoint results http://www.matthewkimber.com/images/so/dataInsideTheActionMethod.png
This, of course, is the stripped down test. I've tried encoding it, decoding it both in the view and in the controller to no avail.
By default everything is encoded when you use razor. I think you're looking for the Raw method.
It would also be a good idea to check the response using Fiddler or Firebug.
Try this:
#Html.DisplayTextFor(modelItem => item.Note)
You can also use HtmlString("")

Is jquery.validate.unobtrusive Bugged?

I am trying to get my clienside validation to work when using an ajax request in a jquery ui dialog.
This means I have no submit button and I do no post back. I could not figure out why I could not get it to work.
I posted this question . I been playing around with it can come to the conclusion is that for whatever reason I need to load up the jquery.validate.unobtrusive with my partial view. It makes no sense to me.
Is this a bug?
Edit
I also gone and posted the error on the asp.net codeplex
The added benefit to this is that if you wish you can just download my little sample application and try it out.
Or you can Follow these steps
Make an non empty asp.net mvc 3 application( I am using razor)
_Layout.cshtml
#ViewBag.Title
<script type="text/javascript">
$(function ()
{
$.get('/home/dialog', null, function (r)
{
var a = $("#dialog").dialog({
resizable: false,
height: 500,
modal: true,
buttons: {
"Delete all items": function ()
{
$('#testFrm').validate().form();
},
Cancel: function ()
{
$(this).dialog("close");
}
}
}).html(r);
});
$('#testFrm').live('submit',function (e)
{
e.preventDefault();
});
});
</script>
</head>
<body>
<div class="page">
<div id="header">
<div id="title">
<h1>My MVC Application</h1>
</div>
<div id="logindisplay">
#Html.Partial("_LogOnPartial")
</div>
<div id="menucontainer">
<ul id="menu">
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li>#Html.ActionLink("About", "About", "Home")</li>
</ul>
</div>
</div>
<div id="main">
#RenderBody()
<div id="footer">
</div>
</div>
</div>
</body>
</html>
ViewUserControl1 (Partial View) - Stick in Home View folder
#model MvcApplication1.Models.TestModel
#using (Html.BeginForm("test","Account",FormMethod.Post,new {#id="testFrm"}))
{
#Html.ValidationSummary()
#Html.TextBoxFor(x => x.Name)
}
Index (should exist replace with this)
#model MvcApplication1.Models.TestModel
#{
ViewBag.Title = "Home Page";
}
<h2>#ViewBag.Message</h2>
<p>
To learn more about ASP.NET MVC visit http://asp.net/mvc.
</p>
#DateTime.Now
<div id="dialog">
</div>
note the dialog id this will be where the ajax request of the partial view gets stored
Home Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcApplication1.Controllers
{
public class HomeController : Controller
{
public ActionResult test()
{
return null;
}
public PartialViewResult Dialog()
{
return PartialView("ViewUserControl1");
}
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
return View();
}
public ActionResult About()
{
return View();
}
}
}
TestModel.cs // view model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;
namespace MvcApplication1.Models
{
public class TestModel
{
[Required()]
public string Name { get; set; }
}
}
web.config
<appSettings>
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
Now run the application. Click "Delete all items" and "Submit Query".
Nothing should happen. No validation pops up for me.
Now go and add this line to the Partial View(ViewUserControl1)
<script src="../../Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>
#model MvcApplication1.Models.TestModel
#using (Html.BeginForm("test","Account",FormMethod.Post,new {#id="testFrm"}))
{
#Html.ValidationSummary()
#Html.TextBoxFor(x => x.Name)
<input type="submit" />
}
Now try again.
It should now come up with validation errors.
I think I found some sort of a work around. Even though I think a automatic way should be done for something so basic as making the validation work with partial views
Work around
This is not a bug. When you load a PartialView using Ajax, you must then parse the unobtrusive validation attributes included in the new elements you are loading.
See http://forums.asp.net/t/1651961.aspx/1?Unobtrusive+validation+not+working+on+form+loaded+by+Ajax

ASP.NET MVC Ajax.BeginForm doesn't work

<script src="../../Scripts/MicrosoftAjax.debug.js" type="text/javascript"></script>
<script type="text/javascript">
function loginOK()
{
var item = document.getElementById('statusLabel');
item.innerHTML = "OK";
document.getElementById('LoadImg').style.visibility = 'hidden';
}
function process()
{
var lab = document.getElementById('statusLabel');
lab.innerHTML = 'Checking...';
lab.style.color = 'Black';
document.getElementById('LoadImg').style.visibility = 'visible';
}
function fail()
{
var lab = document.getElementById('statusLabel');
lab.innerHTML = 'Login is being used';
lab.style.color = 'Red';
document.getElementById('LoadImg').style.visibility = 'hidden';
}
</script>
<div style="width:30%; float:left;">
<label for="Login">Login:</label>
<%= Html.TextBoxFor(model=>model.Login) %>
<%= Html.ValidationMessageFor(model=>model.Login) %>
<img id="LoadImg" alt="" src="../../Content/Images/ajax-loader.gif" style="visibility:hidden;"/>
<br />
<label id="statusLabel" />
<br />
<%=Ajax.ActionLink("CheckLogin","CheckLoginAvailability", "Account",
new AjaxOptions { UpdateTargetId = "statusLabel", OnBegin = "process", OnFailure = "fail", OnSuccess="loginOK"})%>
</div>
and, in the AccountController:
[AcceptVerbs(HttpVerbs.Post)]
public void CheckLoginAvailability(string login)
{
//do some job
}
And, FireBug says that /Account/CheckLoginAvailability is not found. Also, after callback that ActionLink is hidden. Why ?
You are talking about Ajax.BeginForm in your question but this is nowhere to be seen in the markup you provided. There are a couple of issues that I can see with your code:
Your action method doesn't return an ActionResult. Yeah I know, you will say that this is possible, right, but that's against any good practices, conventions and rendering your controllers unit-test friendly.
You are using Microsoft Ajax which will mix markup and javascript which IMHO is bad for multiple reasons: increasing bandwidth which of course leads to decreased performance, incapacity to externalize javascript into separate files in order to cache them by client browsers, having to write things like document.getElementById, innerHTML, style.color, style.visibility, etc... which is not guaranteed to work cross browser.
Here's what I would suggest you to improve this. While this doesn't answer your question, take it as an alternative approach.
As always the first thing to deal with is to define a model which in your case might look something like this:
public class LoginViewModel
{
public string Login { get; set; }
}
Of course you might wish to add other fields such as Password, but this is out of scope for the moment. The next step is to write a controller dealing with this model (in parallel you should be already setting a unit-test for the future controller to prepare the ground):
public class HomeController : Controller
{
public ActionResult Index()
{
// Simply return the Login form
return View(new LoginViewModel());
}
[HttpPost]
public ActionResult Index(LoginViewModel model)
{
// Deal with the actual authentication, etc...
throw new NotImplementedException();
}
[HttpPost]
public ActionResult CheckLoginAvailability(LoginViewModel model)
{
// TODO: query your datasource to determine whether
// model.Login is taken
// For this purpose we will suppose that it is taken
bool isLoginTaken = true;
// return a JSON object containing the result
return Json(new { IsLoginTaken = isLoginTaken });
}
}
The last part is to paint the screen:
<%# Page Language="C#" Inherits="System.Web.Mvc.ViewPage<SomeNs.Models.LoginViewModel>" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Login</title>
<!-- Use a separate CSS to avoid mixing markup with styling -->
<link rel="stylesheet" type="text/css" href="<%: Url.Content("~/content/site.css") %>" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<!-- Always use HTML helpers when dealing with Urls -->
<script type="text/javascript" src="<%: Url.Content("~/scripts/login.js") %>"></script>
</head>
<body>
<% using (Html.BeginForm()) { %>
<%: Html.LabelFor(x => x.Login) %>:
<%: Html.TextBoxFor(x => x.Login) %>
<%: Html.ValidationMessageFor(x => x.Login) %>
<br/>
<!-- Always use HTML helpers when dealing with Urls -->
<img id="loadImg" alt="" src="<%: Url.Content("~/content/images/ajax-loader.gif") %>" style="display:none;" />
<br />
<div id="statusLabel"></div>
<br />
<!-- Give this link an id so that we can easily identify it from javascript -->
<%: Html.ActionLink("CheckLogin", "CheckLoginAvailability", "Home", null, new { id = "checkLogin" })%>
<input type="submit" value="Login" />
<% } %>
</body>
</html>
And the last part is to unobtrusively attach our javascript (using jQuery of course) in the login.js file:
// When the DOM is ready
$(function () {
// Attach a click handler to the checkLogin link
$('a#checkLogin').click(function () {
// When this link is clicked send an AJAX POST request
// to the address this link is pointing to
$.ajax({
type: 'POST',
url: this.href,
// Pass as parameter in the POST body the login
// entered by the user
data: { login: $('#Login').val() },
beforeSend: function () {
// show the spinner image before sending any AJAX request
// to inform the user of an ongoing activity
$('#loadImg').show();
},
complete: function () {
// hide the spinner image when the AJAX request completes
// no matter if it succeeded or not
$('#loadImg').hide();
},
success: function (result) {
// if the AJAX request succeeds
// query the IsLoginTaken property
// of the resulting JSON object
if (result.IsLoginTaken) {
// Show the status label with red if the login is taken
$('#statusLabel').html('Login is being used').css('color', 'red');
} else {
// Show the status label in black if the login is not taken
$('#statusLabel').html('OK').css('color', 'black');
}
}
});
return false;
});
});
As #SLaks says actions can return void but, I think the action signature is such that it is required to return an action result and you can return EmptyResult if you don't want to return anything.
see this http://www.asp.net/mvc/tutorials/asp-net-mvc-controller-overview-cs
try changing your AccountController to
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult CheckLoginAvailability(string login)
{
//do some job
return new EmptyResult();
}

Resources