ASP.NET - consumes web service - only https - how?

I have web services built using ASP.NET and ASP.NET clients. When you're using web services, how do I get clients to use https?

I don't want the whole site to use https by enabling the required SSL in IIS.

Can I use the IIS7 URL Rewriter Module to redirect HTTP requests to https?

+2


a source to share


2 answers


No, you cannot use URL rewriting to change the protocol.



Instead, you can simply inject validation into your web service and throw an exception if the HTTP protocol.

+3


a source


Can you add your web services to the virtual directory and just force the virtual directory to use SSL? Along with the validation inside webservice calls, as Fedor suggests, you can add validation Application_BeginRequest

to yours global.asax

, although this is not very neat:



void Application_BeginRequest(object sender, EventArgs e)
{
     if (!Request.IsSecureConnection && Request.Url.ToString().Contains(".asmx"))
     {
        string secureUrl = Request.Url.ToString().Replace("http:", "https:");
        Response.Redirect(secureUrl);
     }
}

      

+3


a source







All Articles