Click here to Skip to main content
15,884,425 members
Articles / Security

WCF REST 4.0 Authorization with Form Based Authentication (SetAuthCookie)

Rate me:
Please Sign up or sign in to vote.
4.88/5 (24 votes)
19 Mar 2013CPOL2 min read 89.4K   1.8K   51  
How to create custom authorization policy and return HTTPContext Identity for authorization.
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Web;
using System.Web.Routing;
using System.IdentityModel.Policy;


namespace WcfRestService2
{
    public class Global : HttpApplication
    {
        void Application_Start(object sender, EventArgs e)
        {
            RegisterRoutes();
        }

        private void RegisterRoutes()
        {
            // Edit the base address of Service1 by replacing the "Service1" string below
            WebServiceHostFactory hostFactory = new WebServiceHostFactory();
            ServiceRoute route = new ServiceRoute("Service1", hostFactory, typeof(Service1));
            RouteTable.Routes.Add(route);

        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
I work as a freelance consultant and is passionate about taking challenges in latest technology.
I am a solution architect and trainer with 9+ years experience in designing, developing and maintaining enterprise wide application using latest technology like SharePoint 2010, MOSS 2007, Business Intelligence, SQL Server 2008, Reporting Service, Analysis Service and Integration service.

Comments and Discussions