Exposing a custom .svc stored in /Sitefinty/Services

Posted by Community Admin on 04-Aug-2018 02:00

Exposing a custom .svc stored in /Sitefinty/Services

All Replies

Posted by Community Admin on 29-Aug-2012 00:00

Is it at all possible to expose a .svc file that I made living in /Sitefinity/Services?

I've tried combinations in the web.config with the location tag, but nothing seems to work...

<location path="Sitefinity/Services/X/X.svc">
    <system.web>
        <authorization>
            <allow users="*" />
        </authorization>
    </system.web>
</location>

When I'm not authenticated it throws

HTTP Error 401.0 - Unauthorized

You do not have permission to view this directory or page.

...when I want to allow anon users access

Posted by Community Admin on 29-Aug-2012 00:00

I could be totally wrong about this, but I believe you need to register the service using ObjectFactory with something like:

ObjectFactory.RegisterWebService(typeof(MyService), "Sitefinity/Services/MyServices/MyService.svc");

If this is for a custom module you'd do this in the Initialize() method. Otherwise you'd need to do it on App_Start in Global.asax.

But again, this is just my assumption based on how the other modules are registered... hope this is helpful!

Posted by Community Admin on 29-Aug-2012 00:00

Well I mean the service WORKS...when I'm logged in, but not at all for anon, wont let me to that url b/c it's blocked behind /Sitefinity/

Registering it makes it public?

Posted by Community Admin on 06-Sep-2012 00:00

Hello Steve,

Yeah, this directory is protected for security reasons. If you want to expose a custom service, you should place the service here:

SitefinityRoot/Sitefinity/Public/Services

If you want to store it in the protected services folder, I'd suggest you using 

SystemManager.RegisterWebService(serviceType, appRelativeUrl);

..somewhere on the application start. 

Hope this helps. 

Regards,
Georgi
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed