MVC :: Custom Template For Web.config In View Folder?
Dec 6, 2010
I've created a class which extends System.Web.Mvc.ViewPage which I want to be the default class each view inherits from. This is controlled by the "pageBaseType" attribute in the "pages" element in the web.config file in each Views folder. If I add a Views folder in Visual Studio, it creates the web.config.
I would like to change the template it uses to do this to use a different value for pagBaseType. I assume there is a template somewhere I could modify, but I don't know where it is.
I would like to set the one template for edit/insert and view in my custom FormView control . But i got these odd exception Unable to cast object of type 'System.Web.UI.LiteralControl' to type 'System.Web.UI.WebControls.Table'.
public class CustomFormView : FormView { [PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(FormView), BindingDirection.TwoWay)] public IBindableTemplate FormTemplate { get; set; } protected override void OnInit(EventArgs e) { ChangeMode(FormViewMode.Edit); if (FormTemplate != null) { if (CurrentMode == FormViewMode.Edit) { FormTemplate.InstantiateIn(this); } } base.OnInit(e); } } edited : in the first step , I created the new user control and added a formview ("FV") public partial class Form : UserControl { private IBindableTemplate _template = null; [PersistenceMode(PersistenceMode.InnerProperty), TemplateContainer(typeof(FormView), System.ComponentModel.BindingDirection.TwoWay)] public IBindableTemplate FormTemplate { set;get } protected void Page_Init() { if (FormTemplate != null) { FV.InsertItemTemplate = FV.EditItemTemplate = FormTemplate; if (!IsPostBack) FormTemplate.InstantiateIn(FV); } } }
Now , I want to convert this user control to web control.
I had just a little question. I create an empty MVC 2 web site and in the Views folder there is a "web.config" file why? why in "Views" folder and not in the "Controllers" folder?It's not a big problem for me, but i just want to understand
I have created a custom control from scratch and it works fine as in you can build the project that uses it and it works fine at runtime. Problem is when you go to design view the control shows an error in the place of where the control should be rendered.
Error: '<SomeValue>' Could not be set to '<SomeProperty>'
This shows up on all my custom set properties. These properties are created as basic as possible. I can give the properties values in Source view and run the app just fine. I can even add a Onclick event. If I don't set any custom properties the control will render fine in Design view. It's only when I set a value to a custom property.
Property Code Example:
[Code]....
I've even removed the Category and Description tags with no difference.
I don't know if what I said makes sens, but I hope it does.
I am trying to deny access to my 'Admin' folder via web.config. I looked at another answer to a similar question and they recommend using the <location> folder, however when I insert "Admin/" into the path I get the following error:
I need to restric access to my admin folder to certain people. Those with no authentication ticket should be redirectered to a "not allowed page". How do I identify all pages in my admin folder. I have so far but is it OK?
If url.Contains("/admin") Then 'If authentication ticket incorrect then `Response.Redirect("~/notallowed_admin.aspx")` End If
And not, I cannot use my web.config for this particular issue.
I've seen a few postings about MVC's inability to recognize a web.config in the areas sub folder.
I have a situation where each area is in a separate solution/project. There is history and organizational goals that prevents us from following the current standard. Is there anyway possible mechanism for me to dynamically load the web.config located anywhere within the area?
I've looked at the WebConfigManager but I believe that just opens the config and returns a configuration object. It doesn't really load the web.config in the current context.
I seem to be having a problem with my visual studio 2005/2008 installation or something because it isn't providing any IntelliSense whatsoever for controls registered on web.config files in folders different from the root, but it isn't showing any errors neither. Is this behavior normal?
I have access only to the folder of my sub-app, so I can't modify the root's web.config file. Well I COULD, but I'm NOT allowed to.
What I'm trying is to register some WebUserControl's on the web.config file for sub-app folder, so all the pages in my sub-app can use the WebUserControl's without having to register them on every page, but I'm not getting IntelliSense for those controls registered on the web.config file on my sub-app folder, but I do get IntelliSense if I register them on the root's web.config file. IntelliSense for everything else appears to be working fine.
In the web.config file on my sub-app folder I have something like the following:
[code]....
am I doing something wrong?
Update Now I have upgraded to VS2008 SP1 and the issue persist
I have the following IIS folder configuration:WebSiteX - a web site contains a ASP.NET application with a web.config file WebSiteXApp - a virtual directory (App) under WebSiteX, with a different ASP.NET application and a different web.config file.What can I do to prevent the web.config file from the WebSiteX to be inherited when accesing the ASP.NET application from WebSiteXApp, in other words, when I access the WebSiteX/App ASP.NET application I want only the web.config from that application to be considered.
There are some folders in my application that are only accessible by users in certain roles.In order to protect the contents of these folders, I placed web.config files in them which look like so:
[Code...]
Also,in the main web.config file, I have this configured:
[Code...]
However,when I try to access a folder that I'm not authorized to access, I'm not being redirected to unauthorized.aspx page as indicated in the main web.config. Instead,I'm getting sent to the login page.Any idea what I'm doing wrong? Here's the authentication section from the main web.config:
I have a problem configuring web.config file. In root directory I have a web site that doesn't require logging in to be viewed (public section of the web site) and I also have a folder ("Administration") that needs logging in to get access to it. Login.aspx is located in folder "Administration".
The question is how to properly set up the web.config to connect Administration/Login.aspx with Administration/Default.aspx. I tried editing web.config in root directory by adding the following lines, but it only shows me Login.aspx and it redirects me to the public section:
[Code]....
Do I also have to add web.config in "Administration" folder and with which parameters?
I'm using ASP.NET MVC 3 right now with unobtrusive jquery client validation. By default, ValidationMessageFor generates a span tag with certain classes and attributes set. I would like it to generate a different template instead. For example, I might want a div tag with a certain background image.Is this possible at all, or can I just obtain the plain text error message from there so I can do my own styling?
the following web.config file is placed in a specific sub-folder on a website. It will allow the user John.Doe to access the pages inside the folder but will deny anonymous users
Is it possible to replace users in the following web.config file with certain session variable for example getting the day(sunday, monday, etc) from date and storing it in session("DayVar")
then the code should be something like this for the subfolder monday
Using Visual Studio 2008, I need to create a custom web form that when picked acts like the web content form, by providing a dialog that lets you pick a master page. I have looked through the webform.zip template and thought I had a clue, but trying different combinations has baffled me as it either doesn't appear or doesn't work.
Also when you set the project type to Web and sub project type to CSharp it doesn't appear, so I don't know if this part of the cause, because I would of hoped that the SupportsMasterPage element would of caused this dialog to appear, if it is a web item, but no luck. Frown
p.s. I have used my googling resources to the maximum so unsure what to do.
I implemented the Location tag in the web.config file to authorize the anonymous users for Images folder. I deployed the code in IIS6.0 with Forms authentication mode enabled for the virtual directory. I disabled all other authentication modes. When I browse the login page, Images are not displaying. When I set Anonymous authentication in IIS6.0 for the Image folder, it works fine.
Say I have a DisplayTemplate called String.ascx and all string properties get rendered using this style, even if I don't have a UIHint attribute on the model class.
Now, I want a way to say..
'for this particular string property, don't use the template and render normally'.
I don't want to create another template with a default rendering.
So is there any [UIHint(Ignore)] or some such way?
i have a problem with forms authentication. i have a website and want to restrict access to an especific folder. i want the access to this folder be made via the login form this is what i have in the web.config
I'm trying to write a custom rendering template for use in the DisplayForm of a list whose fields include Title, HeaderImageUrl, Body. I've got the following so far: