we trying build more loosely coupled composite based web application, , looking @ various options , frameworks.
the idea when user browse page, uri resolved on server resource , list of actions take based on configuration.
the view composed html markups , components based on other uris contents. components reusable , should not have ideas each other (maybe context).
this idea, , wanna see how openrasta framework on this. might wrong approach; maybe can done current asp.net webform , mvc framework, see opinion.
i have completed openrasta site relies on standard webcontrols inject views, passing on typed resource (supplied or via handler) enable control surface resource properties etc in usual way.
the resource instance carries path control loaded , injected (resource.controlpath). set in handler concatenating aspects of uri find control. allows different uris request different versions of same control live @ different locations in site file hierarchy.
so, example, clienta requires intro view lots of client-specific text , features. clientb requires intro page different content , features.
this give 2 uris
- /myapp/clienta/intro
- /myapp/clientb/intro
configuration
resourcespace.has.resourcesoftype<introresource>() .aturi("/myapp/{client}/intro") .handledby<introhandler>() .renderedbyaspx("~/views/introview.aspx");
introhandler.cs
public class introhandler { public operationresult get(string client) { var controlpath = clientservice.getintrocontrolpath(client); if (controlpath.isempty()) return new operationresult.notfound(); return new operationresult.ok{ responseresource = new introresource{ controlpath = controlpath, client=client } }; } } }
intro.aspx
<%@ page language="c#" inherits="openrasta.codecs.webforms.resourceview<xx.introresource>" masterpagefile="~/views/view.master" %> <asp:content contentplaceholderid="head" id="head" runat="server"> <link href="/assets/css/intro.css" rel="stylesheet" type="text/css" /> <% var usercontrol = page.loadcontrol(resource.controlpath) usercontrol; if (usercontrol == null) return; var property = usercontrol.gettype().getproperty("resource"); if (property == null) return; property.setvalue(usercontrol, resource, null); introcontentcontrolholder.controls.add(usercontrol); %> </asp:content> <asp:content contentplaceholderid="body" id="content" runat="server"> <asp:placeholder runat="server" id="introcontentcontrolholder"></asp:placeholder> </asp:content>
intro.ascx
<%@ control codebehind="intro.ascx.cs" language="c#" inherits="xxxx.intro"%> <h1>welcome <%=resource.client%></h1> ...lots more ui stuff
intro.ascx.cs
public class intro : usercontrol { public introresource resource { get; set; } }
therefore each version of intro control extends view client specific features.
Comments
Post a Comment