Trying to move DynamicData folder into secure Admin folder

Last post 07-08-2009 9:12 PM by ricka6. 4 replies.

Sort Posts:

  • Trying to move DynamicData folder into secure Admin folder

    07-05-2009, 1:59 AM
    • Member
      246 point Member
    • headmax
    • Member since 12-31-2007, 6:05 PM
    • Calgary Alberta Canada
    • Posts 230

     I would like to move the dynamicdata folder into a secure admin folder. Doing so and then trying to access the default.aspx page throws the error:

    The file '/REMOVEDTHISPART/DynamicData/PageTemplates/ListDetails.aspx' does not exist.

    How to fix?

  • Re: Trying to move DynamicData folder into secure Admin folder

    07-05-2009, 7:55 AM
    • Star
      12,328 point Star
    • sjnaughton
    • Member since 04-29-2008, 5:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,567
    • TrustedFriends-MVPs

     Have a look at David Ebbo's blog post Using Dynamic Data with multiple databases where he shows how to change the default folder of DD.

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
    Filed under:
  • Re: Trying to move DynamicData folder into secure Admin folder

    07-06-2009, 1:57 PM
    • Member
      246 point Member
    • headmax
    • Member since 12-31-2007, 6:05 PM
    • Calgary Alberta Canada
    • Posts 230

    sjnaughton:

     Have a look at David Ebbo's blog post Using Dynamic Data with multiple databases where he shows how to change the default folder of DD.

     

    I have worked through the blog post, and the associated forum post. Though I see the connection to my question, I do not understand how to integrate the new pathway portions of that global.asax file.

    Modifying the default global.asax provided by DD to include the new pathways as talked about in that blog post is what I think I need to do,  but I don't know how to do that properly.

     EDIT: I have been able to successfully modify the pathways. Problem now is that security is still not working. Any user, not just the admin, can view database tables.

    The default DD page URL is ~/Admin/Default.aspx, but clicking on a table and the URL shows as ~/Clients/ListDetails.aspx (thus no security, because its not in the admin folder...???)

    My global.asax file:

    <%@ Application Language="C#" %>
    <%@ Import Namespace="System.Web.Routing" %>
    <%@ Import Namespace="System.Web.DynamicData" %>
    <%@ Import Namespace="System.Collections.Generic" %>
    
    <script RunAt="server">
        public static Dictionary<string, MetaModel> Models = new Dictionary<string, MetaModel>();
        
        public static void RegisterRoutes(RouteCollection routes) {
            RegisterContext(routes, "L2S_COD", typeof(CODDataContext), "~/Admin/DynamicData");
        }
    
        private static void RegisterContext(RouteCollection routes, string dbName, Type contextType, string ddFolder) {
            var model = new MetaModel() {
                DynamicDataFolderVirtualPath = ddFolder,
                FieldTemplateFactory = new FieldTemplateFactory() {
                    TemplateFolderVirtualPath = "~/Admin/DynamicData/FieldTemplates"
                }
            };
    
            model.RegisterContext(contextType, new ContextConfiguration() { ScaffoldAllTables = true });
    
            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action = PageAction.List,
                ViewName = "ListDetails",
                Model = model
            });
    
            routes.Add(new DynamicDataRoute("{table}/ListDetails.aspx")
            {
                Action = PageAction.Details,
                ViewName = "ListDetails",
                Model = model
            });
        }
    
        void Application_Start(object sender, EventArgs e) {
            RegisterRoutes(RouteTable.Routes);
        }
    
    </script>

     

  • Re: Trying to move DynamicData folder into secure Admin folder

    07-07-2009, 5:30 AM
    • Star
      12,328 point Star
    • sjnaughton
    • Member since 04-29-2008, 5:11 PM
    • Newton-le-Willows, Merseyside, UK
    • Posts 2,567
    • TrustedFriends-MVPs

    Hi there, have a look at Dynamic Data Samples Jun 17 2008, which has a sample SecureDynamicData.zip this uses routing to limit access to table based on user roles.

    Steve Big Smile

    Always seeking an elegant solution.
    [Oh! If olny I colud tpye!]
    c# Bits blog
    Oh, and don't forget to mark as answer any posts that help you Big Smile
  • Re: Trying to move DynamicData folder into secure Admin folder

    07-08-2009, 9:12 PM
    • Contributor
      5,850 point Contributor
    • ricka6
    • Member since 06-25-2008, 6:04 PM
    • Redmond
    • Posts 940
    • AspNetTeam
      Moderator
Page 1 of 1 (5 items)