dynamic - Overwrite the LoginWidget and Set DestinationPageUrl dynamically in Sitefinity -
i want add custom code during login function, in particular want redirect user after login previous page.
for example: i'm on page , want download page, i'm not authorized. pops popup link login page. after successful login i'm on page a.
for purpose want overwrite loginwidged , set value to"this.destinationpageurl" dynamically.
i read similar issues here , here, there isn't example how overwrite loginwidget class.
i create customlogincontrol.cs file in project , register new custom control, after rendering on page, didn't work. login button not make nothing. i'm not sure have , of methods have overwrite.
namespace sitefinitywebapp.usercontrols { public class customlogincontrol : telerik.sitefinity.web.ui.publiccontrols.loginwidget { protected override void render(system.web.ui.htmltextwriter writer) { this.destinationpageurl = "http://previouspage.com"; base.render(writer); } } }
can give me example how overwrite class work properly.
version: sitefinity 5.0, claims-based authentication
i've done similar instead of overriding login control can subscribe , capture unauthorizedaccess event, send user login page redirect page query string parameter. you'll need add global.asax / global.asax.cs file project, add application_start function:
protected void application_start(object sender, eventargs e) { bootstrapper.initialized += bootstrapperinitialized; }
then add these 2 functions:
private void bootstrapperinitialized(object sender, executedeventargs e) { if (e.commandname == "bootstrapped") { eventhub.subscribe<iunauthorizedpageaccessevent>(onunauthorizedaccess); } } private void onunauthorizedaccess(iunauthorizedpageaccessevent unauthorizedevent) { var manager = configmanager.getmanager(); string loginpage = manager.getsection<projectconfig>().defaultsite.frontendloginpageurl; var redirectparam = unauthorizedevent.redirecturl.replace(string.format("{0}?returnurl=", loginpage), string.empty); var escaped = uri.escapedatastring(redirectparam); unauthorizedevent.httpcontext.response.redirect(string.format("{0}?returnurl={1}", loginpage, escaped)); }
you need set default front end login page in settings under administration -> settings -> advanced -> project -> defaultsite , frontendloginpageurl setting.
this works me on 6.3 site, not sure if available in sitefinity 5 or not.
Comments
Post a Comment