Here i am sharing an example of creating a custom AuthorizeAttribute in mvc4 application, and its implementation.
Step 1 :
Create a class
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = true)]
public class AuthorizeAdminAuthorizeAttribute : AuthorizeAttribute
{
protected override bool AuthorizeCore(HttpContextBase httpContext)
{
var isAuthorized = base.AuthorizeCore(httpContext);
if (!isAuthorized)
{
isAuthorized = false;
}
if (httpContext.User.Identity.Name == null)
isAuthorized = false;
else
isAuthorized = true;
return isAuthorized;
}
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
{
base.HandleUnauthorizedRequest(filterContext);
filterContext.Result = new RedirectToRouteResult(new
RouteValueDictionary(new { controller = "AdminAccount", action = "Index" }));
}
else
{
filterContext.Result = new RedirectToRouteResult(new
RouteValueDictionary(new { controller = "JewelAdmin", action = "Index" }));
}
}
}
Step 2:
Now we see how to call the authorize attribute in action
[AuthorizeAdminAuthorize]
public ActionResult AddProduct()
{
return View();
}
So, now in whichever action you want authorization to be checked , just put [AuthorizeAdminAuthorize] attribute on top of that ActionResult
Tuesday, May 28, 2013
Sunday, March 17, 2013
Asp.net datalist pagging with LINQ SQL
Code Behind :
// Page load implementation :
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
string pagenumber = Request.QueryString["pagenumber"] as string;
if (!string.IsNullOrEmpty(pagenumber))
CurrentPageNumber = Convert.ToInt32(pagenumber);
}
}
void LoadUserDetails()
{
int totalRows = 0;
using (AdminDTO dto = new AdminDTO())
{
dlUserdetails.DataSource = dto.GetAllUsers(CurrentPageNumber, defaultPageSize, ref totalRows, Convert.ToInt32(dlType.SelectedItem.Value));
dlUserdetails.DataBind();
}
TotalPaggingRecords = totalRows;
}
// the property
public int CurrentPageNumber
{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 1; // default page index of 0
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
now lets look at how to page data using LINQ, the following method calls at linq , the pagging tricks is in .Skip((pageNumber - 1) * pageSize).Take(pageSize)
dto.GetAllUsers(CurrentPageNumber, defaultPageSize, ref totalRows, Convert.ToInt32(dlType.SelectedItem.Value)
public List GetAllUsers(int pageNumber, int pageSize, ref int TotalRows, int dType)
{
List users = new List();
using (var context = new DBETNetEntities())
{
TotalRows = context.UserInfoes
.OrderByDescending(ui => ui.CreateDate)
.ToList().Count;
users = context.UserInfoes
.OrderByDescending(ui => ui.CreateDate)
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
.ToList();
}
}
now create a function that will page the data based on page number and rowindex, probably you can make it more genric
public string GetPageNavigation(int currentPageNumber, int pageSize, int totalRecords)
{
decimal _pages = (decimal)totalRecords / (decimal)pageSize;
int pagecount = Convert.ToInt32(Math.Ceiling(_pages)); //Math.Max(_pages);
StringBuilder pageStr = new StringBuilder();
pageStr.Append("< table >< tr>");
pageStr.Append(string.Format("< td >Page {0} of< /td >", CurrentPageNumber));
pageStr.Append(string.Format("< td >Records {0} < /td >", TotalPaggingRecords));
pageStr.Append("< td style='background-color:#ccc;width:18px;'> < /td>");
for (int i = 1; i <= pagecount; i++)
{
if (i == currentPageNumber)
pageStr.Append(string.Format("< td style='background-color:#000;color:#fff;border:1px solid #e7e7e7;' >{0}< /td>", i));
else
pageStr.Append(string.Format("< td style='background-color:#fff;border:1px solid #e7e7e7;' > < a href='ControlPanel.aspx?pagenumber={0}' >{1}< /a>< /td>", i, i));
if (i >= 25)
{
pageStr.Append(string.Format("< td style='background-color:#fff;border:1px solid #e7e7e7;'> < a href='ControlPanel.aspx?pagenumber={0}' >Next< /a >< /td >", (currentPageNumber + 1)));
break;
}
}
pageStr.Append("< /tr>< /table >");
return pageStr.ToString();
}
Pagging is done, now lets look how to call the pagging from html implementation
< div style="margin: 2px; padding: 4px; border: 1px solid #ccc; background-color: #f5f5f5;" >
< %=GetPageNavigation(CurrentPageNumber, defaultPageSize, TotalPaggingRecords)% >
< /div >
// Page load implementation :
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
string pagenumber = Request.QueryString["pagenumber"] as string;
if (!string.IsNullOrEmpty(pagenumber))
CurrentPageNumber = Convert.ToInt32(pagenumber);
}
}
void LoadUserDetails()
{
int totalRows = 0;
using (AdminDTO dto = new AdminDTO())
{
dlUserdetails.DataSource = dto.GetAllUsers(CurrentPageNumber, defaultPageSize, ref totalRows, Convert.ToInt32(dlType.SelectedItem.Value));
dlUserdetails.DataBind();
}
TotalPaggingRecords = totalRows;
}
// the property
public int CurrentPageNumber
{
get
{
// look for current page in ViewState
object o = this.ViewState["_CurrentPage"];
if (o == null)
return 1; // default page index of 0
else
return (int)o;
}
set
{
this.ViewState["_CurrentPage"] = value;
}
}
now lets look at how to page data using LINQ, the following method calls at linq , the pagging tricks is in .Skip((pageNumber - 1) * pageSize).Take(pageSize)
dto.GetAllUsers(CurrentPageNumber, defaultPageSize, ref totalRows, Convert.ToInt32(dlType.SelectedItem.Value)
public List
{
List
using (var context = new DBETNetEntities())
{
TotalRows = context.UserInfoes
.OrderByDescending(ui => ui.CreateDate)
.ToList
users = context.UserInfoes
.OrderByDescending(ui => ui.CreateDate)
.Skip((pageNumber - 1) * pageSize).Take(pageSize)
.ToList
}
}
now create a function that will page the data based on page number and rowindex, probably you can make it more genric
public string GetPageNavigation(int currentPageNumber, int pageSize, int totalRecords)
{
decimal _pages = (decimal)totalRecords / (decimal)pageSize;
int pagecount = Convert.ToInt32(Math.Ceiling(_pages)); //Math.Max(_pages);
StringBuilder pageStr = new StringBuilder();
pageStr.Append("< table >< tr>");
pageStr.Append(string.Format("< td >Page {0} of< /td >", CurrentPageNumber));
pageStr.Append(string.Format("< td >Records {0} < /td >", TotalPaggingRecords));
pageStr.Append("< td style='background-color:#ccc;width:18px;'> < /td>");
for (int i = 1; i <= pagecount; i++)
{
if (i == currentPageNumber)
pageStr.Append(string.Format("< td style='background-color:#000;color:#fff;border:1px solid #e7e7e7;' >{0}< /td>", i));
else
pageStr.Append(string.Format("< td style='background-color:#fff;border:1px solid #e7e7e7;' > < a href='ControlPanel.aspx?pagenumber={0}' >{1}< /a>< /td>", i, i));
if (i >= 25)
{
pageStr.Append(string.Format("< td style='background-color:#fff;border:1px solid #e7e7e7;'> < a href='ControlPanel.aspx?pagenumber={0}' >Next< /a >< /td >", (currentPageNumber + 1)));
break;
}
}
pageStr.Append("< /tr>< /table >");
return pageStr.ToString();
}
Pagging is done, now lets look how to call the pagging from html implementation
< div style="margin: 2px; padding: 4px; border: 1px solid #ccc; background-color: #f5f5f5;" >
< %=GetPageNavigation(CurrentPageNumber, defaultPageSize, TotalPaggingRecords)% >
< /div >
Saturday, March 16, 2013
Add, Update with Entity Framework 5
CRUD sample with Entity Framework 5.
in EF 5 there is something called DBContext, which is little different than earlier ObjectContext, DBContext generate less code to achieve the same functionality, and is based on code first principle
this is how the dbcontext file look like and connection string to be set
public partial class GoldEntities : DbContext
{
static string secureConnectionString = Util.EntityFrameworkConnectionString;
public GoldEntities()
: base(secureConnectionString)
{
}
}
ADD :
public bool AddDesignType(tbProductType designType)
{
bool result = false;
using (var context = new GoldEntities())
{
context.tbProductTypes.Add(designType);
context.SaveChanges();
result = true;
}
return result;
}
UPDATE using Entityframework 5:
to update an entity you wont find applychanges method, so here is how you can update an entity.
public bool UpdateColorStoneName(tbColorStoneName colorStoneName)
{
bool isSaved = false;
using (var context = new GoldEntities())
{
tbColorStoneName csn = context.tbColorStoneNames
.Where(d => d.ColorStoneNameId == colorStoneName.ColorStoneNameId)
.FirstOrDefault();
if (csn != null)
{
context.Entry(csn).State = EntityState.Modified;
context.SaveChanges();
isSaved = true;
}
}
return isSaved;
}
in EF 5 there is something called DBContext, which is little different than earlier ObjectContext, DBContext generate less code to achieve the same functionality, and is based on code first principle
this is how the dbcontext file look like and connection string to be set
public partial class GoldEntities : DbContext
{
static string secureConnectionString = Util.EntityFrameworkConnectionString;
public GoldEntities()
: base(secureConnectionString)
{
}
}
ADD :
public bool AddDesignType(tbProductType designType)
{
bool result = false;
using (var context = new GoldEntities())
{
context.tbProductTypes.Add(designType);
context.SaveChanges();
result = true;
}
return result;
}
UPDATE using Entityframework 5:
to update an entity you wont find applychanges method, so here is how you can update an entity.
public bool UpdateColorStoneName(tbColorStoneName colorStoneName)
{
bool isSaved = false;
using (var context = new GoldEntities())
{
tbColorStoneName csn = context.tbColorStoneNames
.Where(d => d.ColorStoneNameId == colorStoneName.ColorStoneNameId)
.FirstOrDefault
if (csn != null)
{
context.Entry
context.SaveChanges();
isSaved = true;
}
}
return isSaved;
}
Tuesday, February 26, 2013
Loading dropdownlist in MVC2 and MVC4
Loading doropdownlist in MVC2 and MVC4.
This is the code you will write in Models, here you create a cs file called ProfileModel inside Models folder an write the following code.
public interface IAdminService
{
List< tblCountry > GetCountries();
}
public class AdminService : IAdminService
{
/* this you can cosider as data provider, like any Services, any other assembly etc. */
AdminDTO _adminProvider;
MasterDTO _masterProvider;
public AdminService()
{
_adminProvider = new AdminDTO();
_masterProvider = new MasterDTO();
}
public List< tblCountry > GetCountries()
{
return MasterDTO.GetContries();
}
}
now here we see how to call the dataService in controller
public class ProfileController : Controller
{
public IDataService dataService { get; set; }
protected override void Initialize(RequestContext requestContext)
{
if dataService == null) { dataService = new DataService(); }
base.Initialize(requestContext);
}
/* this is an example of view implementation in example */
[HttpGet]
public ActionResult ManageProfile()
{
ViewBag.Countries = dataService.GetCountries();
ViewBag.Message = string.Format("There are {0} contries", dataService.GetCountries().Count);
List countryList = (from p in
dataService.GetCountries().ToList()
select new SelectListItem()
{
Value = p.CountryId.ToString(),
Text = p.CountryName
}).ToList();
ViewBag.CountryDropdown = countryList;
return View();
}
}
Now your view is ready with data, you just need to display on screen , so here is how you can achieve that.
In "Views" folder you need to create a folder called "Profile", inside the "Profile" folder create a razor page with name ManageProfile, and write the code below.
this is an example of country dorpdown, "CountryDropdown" is nothing but the variable of your view bag
@Html.DropDownList("CountryDropdown")
this is an example of how the collection object can be displayed like datalist/gridview/collectionbinding
@{
var countries = ViewBag.Countries;
}
< table >
@foreach (tblCountry c in countries)
{
< tr >
< td >@c.CountryId
< /td >
< td >
@Html.ActionLink(c.CountryName, "AddEditState", new { cid = c.CountryId, name = c.CountryName });
< /td >
< td >@c.CurrencyCode
< /td >
< td >@c.Currency
< /td >
< td >@c.Capital
< /td >
< td >@c.Population
< /td >
< /tr >
}
< /table >
please note : example how to pass parameters with Html.ActionLink() @Html.ActionLink(c.CountryName, "AddEditState", new { cid = c.CountryId, name = c.CountryName });
This is the code you will write in Models, here you create a cs file called ProfileModel inside Models folder an write the following code.
public interface IAdminService
{
List< tblCountry > GetCountries();
}
public class AdminService : IAdminService
{
/* this you can cosider as data provider, like any Services, any other assembly etc. */
AdminDTO _adminProvider;
MasterDTO _masterProvider;
public AdminService()
{
_adminProvider = new AdminDTO();
_masterProvider = new MasterDTO();
}
public List< tblCountry > GetCountries()
{
return MasterDTO.GetContries();
}
}
now here we see how to call the dataService in controller
public class ProfileController : Controller
{
public IDataService dataService { get; set; }
protected override void Initialize(RequestContext requestContext)
{
if dataService == null) { dataService = new DataService(); }
base.Initialize(requestContext);
}
/* this is an example of view implementation in example */
[HttpGet]
public ActionResult ManageProfile()
{
ViewBag.Countries = dataService.GetCountries();
ViewBag.Message = string.Format("There are {0} contries", dataService.GetCountries().Count);
List
dataService.GetCountries().ToList()
select new SelectListItem()
{
Value = p.CountryId.ToString(),
Text = p.CountryName
}).ToList();
ViewBag.CountryDropdown = countryList;
return View();
}
}
Now your view is ready with data, you just need to display on screen , so here is how you can achieve that.
In "Views" folder you need to create a folder called "Profile", inside the "Profile" folder create a razor page with name ManageProfile, and write the code below.
this is an example of country dorpdown, "CountryDropdown" is nothing but the variable of your view bag
@Html.DropDownList("CountryDropdown")
this is an example of how the collection object can be displayed like datalist/gridview/collectionbinding
@{
var countries = ViewBag.Countries;
}
< table >
@foreach (tblCountry c in countries)
{
< tr >
< td >@c.CountryId
< /td >
< td >
@Html.ActionLink(c.CountryName, "AddEditState", new { cid = c.CountryId, name = c.CountryName });
< /td >
< td >@c.CurrencyCode
< /td >
< td >@c.Currency
< /td >
< td >@c.Capital
< /td >
< td >@c.Population
< /td >
< /tr >
}
< /table >
please note : example how to pass parameters with Html.ActionLink() @Html.ActionLink(c.CountryName, "AddEditState", new { cid = c.CountryId, name = c.CountryName });
Tuesday, February 19, 2013
WCF Rest example
Create a WCF Service, Delete the default added service and follow the steps below.
Step 1: Create a object called Student, this object we use in our example
[DataContract]
public class Student
{
[DataMember]
public int StudentId { get; set; }
[DataMember]
public int ClassId { get; set; }
[DataMember]
public string Firstname { get; set; }
[DataMember]
public string Lastname { get; set; }
}
Now create a WCF service with any business name as per your requirement, here i have created a service called RestfulServiceExample.svc , open the interface created with name IRestfulServiceExample, here i have added four example of Json and XML with single object and collection object
Here is how the definition would look like.
using System.ServiceModel;
using System.ServiceModel.Web;
using WcfRestExample.BusinessObjects;
using System.Collections.Generic;
namespace WcfRestExample
{
[ServiceContract(Namespace = "http://arindamachakraborty.blogspot.in")]
public interface IRestfulServiceExample
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "xml/{id}")]
Student XMLStudent(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "json/{id}")]
Student JSONStudent(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "xmls/{id}")]
List XMLStudents(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "jsons/{id}")]
List JSONStudents(string id);
}
}
Note : in WebInvoke attribute Method value is case sensitive, that should always be Method = "GET", not Method = "Get" or Method = "get"
Now lets look at the implementation of interface.
public class RestfulServiceExample : IRestfulServiceExample
{
public Student JSONStudent(string id)
{
return new Student()
{
ClassId = 1,
StudentId = 2,
Firstname = "Arindam",
Lastname = "Chakraborty"
};
}
public Student XMLStudent(string id)
{
return new Student()
{
ClassId = 1,
StudentId = 2,
Firstname = "Arindam",
Lastname = "Chakraborty"
};
}
public List< Student > XMLStudents(string id)
{
List< Student > students = new List< Student >();
students.Add(new Student(){ ClassId=1, Firstname="Arindam", Lastname="Chakraborty", StudentId=1 });
students.Add(new Student() { ClassId = 2, Firstname = "Richa", Lastname = "Pandit", StudentId = 2 });
students.Add(new Student() { ClassId = 3, Firstname = "Soham", Lastname = "Khanna", StudentId = 3 });
return students;
}
public List< Student > JSONStudents(string id)
{
List< Student > students = new List< Student >();
students.Add(new Student() { ClassId = 1, Firstname = "Arindam", Lastname = "Chakraborty", StudentId = 1 });
students.Add(new Student() { ClassId = 2, Firstname = "Richa", Lastname = "Pandit", StudentId = 2 });
students.Add(new Student() { ClassId = 3, Firstname = "Soham", Lastname = "Khanna", StudentId = 3 });
return students;
}
}
We are done with service development, now we look at service configuration and how to publish
< system.serviceModel >
< services >
< service name="WcfRestExample.RestfulServiceExample" behaviorConfiguration="ServiceBehavior" >
< endpoint binding="webHttpBinding"
contract="WcfRestExample.IRestfulServiceExample"
behaviorConfiguration="web" >
< /endpoint >
< /service >
< /services >
Notice we have set binding="webHttpBinding"
< behaviors >
< serviceBehaviors >
< behavior name="ServiceBehavior" >
< !-- To avoid disclosing metadata information,
set the value below to false
and remove the metadata endpoint above before deployment -- >
< serviceMetadata httpGetEnabled="true"/ >
< !-- To receive exception details in faults for
debugging purposes, set the value below to true.
Set to false before deployment to avoid disclosing
exception information -- >
< serviceDebug includeExceptionDetailInFaults="false"/ >
< /behavior >
< /serviceBehaviors >
< endpointBehaviors >
< behavior name="web" >
< webHttp / >
< /behavior >
< /endpointBehaviors >
< /behaviors >
< serviceHostingEnvironment multipleSiteBindingsEnabled="true" / >
< /system.serviceModel >
Now we have successfully built and published the service, so its time to test the service, so you can see how the end result will look like.
Here is the url you need to run
http://machinename/servicename/xml - xml output for single objetc
http://machinename/servicename/xmls - xml output for collection object
http://machinename/servicename/json - json single object
http://machinename/servicename/jsons - json output collection objects
Step 1: Create a object called Student, this object we use in our example
[DataContract]
public class Student
{
[DataMember]
public int StudentId { get; set; }
[DataMember]
public int ClassId { get; set; }
[DataMember]
public string Firstname { get; set; }
[DataMember]
public string Lastname { get; set; }
}
Now create a WCF service with any business name as per your requirement, here i have created a service called RestfulServiceExample.svc , open the interface created with name IRestfulServiceExample, here i have added four example of Json and XML with single object and collection object
Here is how the definition would look like.
using System.ServiceModel;
using System.ServiceModel.Web;
using WcfRestExample.BusinessObjects;
using System.Collections.Generic;
namespace WcfRestExample
{
[ServiceContract(Namespace = "http://arindamachakraborty.blogspot.in")]
public interface IRestfulServiceExample
{
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "xml/{id}")]
Student XMLStudent(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "json/{id}")]
Student JSONStudent(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "xmls/{id}")]
List
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "jsons/{id}")]
List
}
}
Note : in WebInvoke attribute Method value is case sensitive, that should always be Method = "GET", not Method = "Get" or Method = "get"
Now lets look at the implementation of interface.
public class RestfulServiceExample : IRestfulServiceExample
{
public Student JSONStudent(string id)
{
return new Student()
{
ClassId = 1,
StudentId = 2,
Firstname = "Arindam",
Lastname = "Chakraborty"
};
}
public Student XMLStudent(string id)
{
return new Student()
{
ClassId = 1,
StudentId = 2,
Firstname = "Arindam",
Lastname = "Chakraborty"
};
}
public List< Student > XMLStudents(string id)
{
List< Student > students = new List< Student >();
students.Add(new Student(){ ClassId=1, Firstname="Arindam", Lastname="Chakraborty", StudentId=1 });
students.Add(new Student() { ClassId = 2, Firstname = "Richa", Lastname = "Pandit", StudentId = 2 });
students.Add(new Student() { ClassId = 3, Firstname = "Soham", Lastname = "Khanna", StudentId = 3 });
return students;
}
public List< Student > JSONStudents(string id)
{
List< Student > students = new List< Student >();
students.Add(new Student() { ClassId = 1, Firstname = "Arindam", Lastname = "Chakraborty", StudentId = 1 });
students.Add(new Student() { ClassId = 2, Firstname = "Richa", Lastname = "Pandit", StudentId = 2 });
students.Add(new Student() { ClassId = 3, Firstname = "Soham", Lastname = "Khanna", StudentId = 3 });
return students;
}
}
We are done with service development, now we look at service configuration and how to publish
< system.serviceModel >
< services >
< service name="WcfRestExample.RestfulServiceExample" behaviorConfiguration="ServiceBehavior" >
< endpoint binding="webHttpBinding"
contract="WcfRestExample.IRestfulServiceExample"
behaviorConfiguration="web" >
< /endpoint >
< /service >
< /services >
Notice we have set binding="webHttpBinding"
< behaviors >
< serviceBehaviors >
< behavior name="ServiceBehavior" >
< !-- To avoid disclosing metadata information,
set the value below to false
and remove the metadata endpoint above before deployment -- >
< serviceMetadata httpGetEnabled="true"/ >
< !-- To receive exception details in faults for
debugging purposes, set the value below to true.
Set to false before deployment to avoid disclosing
exception information -- >
< serviceDebug includeExceptionDetailInFaults="false"/ >
< /behavior >
< /serviceBehaviors >
< endpointBehaviors >
< behavior name="web" >
< webHttp / >
< /behavior >
< /endpointBehaviors >
< /behaviors >
< serviceHostingEnvironment multipleSiteBindingsEnabled="true" / >
< /system.serviceModel >
Now we have successfully built and published the service, so its time to test the service, so you can see how the end result will look like.
Here is the url you need to run
http://machinename/servicename/xml - xml output for single objetc
http://machinename/servicename/xmls - xml output for collection object
http://machinename/servicename/json - json single object
http://machinename/servicename/jsons - json output collection objects
Subscribe to:
Posts (Atom)