C# - MVC 2 "RequiresRole" Attribute Does Not Work?

Jun 28, 2010

I'm developing a ASP.NET MVC 2 web application. So far, I managed to define access rules for every controller function, using "RequiresRole" attribute.

Suddenly, this way of defining access rules stopped working (now every user can invoke any of the controller methods). :S. I tried debugging, and it seems that user-roles are correct. I tried reviewing web.config, but did not find anything suspicious.

View 1 Replies


Similar Messages:

How Does The ApplicationName Attribute Actually Work

Dec 20, 2010

why did asp.net team choose / as the default value of Membership Role application name rather than the project name that makes sense?

In addition, the application might not be deployed as the root application. It means that / is no longer

Edit 1:

For example: I create a project A first and deploy it. Later I create another project B and deploy it. If both projects use the default, they still work but it will be difficult to know which users come from each project.

For me, it is better if the default is set to the project name.

Edit 2:

I am talking about the applicationName attribute generated by Visual Studio in Web.config.
Why don't use the project name instead of / by default ?

<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider"
applicationName="/" />
</providers>
</roleManager>

EDIT 3:

After creating two applications (i.e., one as the root and the other one as the child app) and both have the same applicationName set to /, both application use the same ApplicationID. It means the slash has nothing to do with site domain tree. My confusion has been answered. So... why did Visual Studio set it to / (that makes confusion for me) by default?

EDIT 4:

I have two applications. One as the root application and the other one as the sub application under the former. Both use applicationName = "/". I got the result as follow in database: So what is the meaning of /? If no meaning, why did VS choose this confusing name rather than the project name?

EDIT 5:

From this article, I will make the summary:

If we remove applicationName attribute from web.config for both applications, the ApplicationName generated in database for the root will be "/" and the ApplicationName generated in database for the sub app will be "/subappvirtualdir".If we leave the applicationName to its default value of "/" for both applications, both root app and sub app will get the same ApplicatonName of "/" generated in database. If we change the applicationName to "any name you want" for both applications, the ApplicationName generated in database will be set to "any name you want" for both applications.

View 2 Replies

Does The SessionState Attribute In MVC 3 Work Properly

Feb 11, 2011

I'm managing a rather large project, written in asp.net webforms + mvc3, with a large user base, and a pretty high daily visitor count. Basically, there are a lot of requests at any given moment.

One of my controllers in MVC that handles / resizes images on the fly has the following attribute applied to it:

[SessionState(SessionStateBehavior.Disabled)]

Now, if an action in the controller tries to access the session - it obviously throws an exception - so we're good so far. The problem is: if I go to the IIS Worker Processes window (Win Server 2008 R2, IIS 7.5), and check the current requests for this site, I can sometimes see the requests to an action in this controller. Their current state is locked in State: RequestAcquireState, Module Name: Session. Sometimes these locks go over a second or two in this state.

Wasn't the whole point of the attribute in the first place to make the requests to the controller ignore the state, and not waste time (and possibly being locked) trying to acquire the state? If this is so - am I doing something wrong here, or does the problem lie elsewhere?

View 1 Replies

Custom Server Controls :: Category Attribute Of User Control Property Does Not Work Correctly In Categories Tab

Aug 19, 2010

I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Code]....

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

View 2 Replies

Forms Data Controls :: Attribute 'onchange' Is Not A Valid Attribute Of Element 'TextBox'

Mar 31, 2011

<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="TextBox1" onchange="calculate()" runat="server" Text="0"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

I'm getting this error on the above markup: Message 1 Validation (ASP.Net): Attribute 'onchange' is not a valid attribute of element 'TextBox'.

View 2 Replies

Web Forms :: Getting Error / Unrecognized Attribute 'targetFramework'. Note That Attribute Names Are Case-sensitive

Mar 17, 2011

I have a problem with my web site 1stSigBdeAssn.org. I have made no changes to the site but I now get the following error message:

Parser Error Message:

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

Source Error:

[code]....

View 4 Replies

Web Forms :: Attribute 'Master' Not Valid Attribute Of Element 'Control'

Feb 1, 2011

I created a simple Master Page in Visual Studio 2008:

<%@
Master
Language="VB"
CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE
html
PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"

and got green underlined 'Master' with two warning messages: 1.Validation (ASP.NET): This attribute name must be followed byan equal (=) sign and a value. If the value is in quotation marks, the quotation marks must match. 2. Validation (ASP.NET): Attribute 'Master' is not a valid attribute of element 'Control'.How I can get rid of the messages?

View 3 Replies

Forms Data Controls :: ListItem Error Message Validation(ASP .Net):Attribute CssClass Is Not A Valid Attribute Of Element ListItem

Sep 17, 2010

I have a tag:

<asp:ListItem
CssClass="LabelCSS">Executive</asp:ListItem>

and I am getting the error message

Validation(ASP .Net):Attribute CssClass is not a valid attribute of element ListItem.

What attribute would I use for Css with ListItem?

View 2 Replies

Configuration :: Unrecognized Attribute "targetFramework" Note That Attribute Names Are Case - Sensitive While Hosting

Nov 29, 2010

i'm trying to host an .net framework4.0 application in IIS7. i got an error while clicking on the manage module in modules .like ("Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive. ") .I changed my application poll to .net4.0.I am able to browse my application

</system.serviceModel>
</configuration>

View 5 Replies

Configuration :: Unrecognized Attribute "targetFramework" - Note That Attribute Names Are Case - Sensitive

Oct 20, 2010

I installed Microsoft Visual Studio 2010 Ultimate Trial and converted existing asp.net 2.0 web application and I am getting this error: znrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive. It's coming from this section in the web.config which was auto-generated by VS2010 when I converted the project:

<compilation defaultLanguage="c#" debug="false" targetFramework="4.0">
<compilers>
<!--<compiler language="c#" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".cs" compilerOptions="/d:DEBUG;TRACE" /></compilers> -->
<compiler language="c#" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".cs"/></compilers>
<assemblies>
<add assembly="Microsoft.JScript, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>

View 1 Replies

C# - Retrieve The Name Of The Attribute Dynamically Without Specifying The Name Of The Attribute?

Aug 13, 2010

I am developing asp.net mobile application. I am using LINQ to XML to query XML file. I am using the following query to retrieve the name & value of the query dynamically as follows

var TotalManifolds = from MF in FieldRoot.Element("FIELD-DEFINITION").Element("MANIFOLDS").Elements("MANIFOLD")
join SLT in FieldRoot.Element("FIELD-DEFINITION").Element("SLOTS").Elements("SLOT")
on (string)MF.Attribute("MID") equals (string)SLT.Attribute("PARENT")
select new
{
SlotName = (string)SLT.Attribute("NAME").Value,
SlotValue = (string)SLT.Attribute("NAME").Value
};

In the following statement of above query I want to retrive the name of the attribure dynamically without explicitly specifying the name of the attribute SlotName = (string)SLT.Attribute("NAME").Value Here I am explicitly specifying the name. I want to code which can dynamically retrieve the name of the attribute. I am new to Linq to xml. how this can be done programatically? or can you provide me the link through which I can resolve the above issue ?

View 2 Replies

Security :: Domain Attribute In Web.config Is Unrecognized Attribute 'domain' In Asp.net 1.1

Jan 21, 2011

I am trying to achieve a SSO implimentation across my websites so i am using the machine key attribute to do so.now the trouble starts here as the website the user logs in is on the .net 1.1 framework and the website it it navigating to is .net 4.0.I have share the same machine-key across both the application . It works fine in my testing environment but as i move to the deployment server ,it just dosent work !So what i could do is read this article on MSDN :

http://msdn.microsoft.com/en-us/library/eb0zx8fc.aspx
this tells me to add a domin attribute like below
<forms loginUrl="~Login.aspx" defaultUrl="Default.aspx" protection="All" timeout="80" name=".ASPXAuth" domain="asbc.com"/>
but this thing just dosent work on the 1.1 application and throws an error Unrecognized attribute 'domain'.

Where do i get to mention the domin in my 1.1 application.?

View 3 Replies

IIS Configuration :: Crystal Reports Work On Local Machine But When Upload It Does Not Work In VS2010

Apr 27, 2016

I have created a crystal following your article which url isĀ 

[URL]

It is working fine on local machine but when i upload it on the server it is not working. Crystal Report is showing but data is not showing in the crystal report.

View 1 Replies

Localization :: Culture Settings Work On Machine - Don't Work When Moved To Server?

Jan 20, 2010

I am working on a multi-language web site. It is half English and half Portuguese. I have created forms that have portuguese values in it. These forms work perfectly on my desktop. I'm using Cassini as the development server. When I move them over to IIS, they are not loading properly. The text comes up all weird looking. I am declaring the culture in the page attribute: Culture="pt-BR"

View 4 Replies

AJAX :: Make This Work For Several Days But It Just Doesn't Work?

Oct 7, 2010

i'm trying to make this work for several days but it just doesn't work.

this is my code:

aspx page:

[Code]....

webservice:

[Code]....

this was downloaded from this website.

the problem is that the page loads fine but no autocomplete occurs.

View 5 Replies

Ajax With WCF Work. But Few Miniute After, Doesn't Work

May 11, 2010

I am a new to WCF. I have written ajax to use a web service before, but on this project I am trying to use ajax to WCF.After I build the project and wcf using ajax, I receive the return successfully. But, 10 or more minutes later I don't get a return, the ajax calls the error function, and the fiddler returns nothing.

If I rebuild the project without any source modifying, I receive the return successfully again.

View 2 Replies

How To Add Attribute To Title Tag

Oct 22, 2010

I'm using webforms ASP.NET, with masterpages. I want to add a LANG attribute to the <title> tag. ASP.NET automatically generates a title tag. I've tried adding my own tag with an ID and runat="server", like this:

<title id="titleBlock" runat="server"></title>

When doing this, I can set an attribute like the following without any errors.

titleBlock.Attributes.Add("lang", "it");

However, ASP.NET wipes out my <title> tag completely and puts its own in without my LANG attribute. Is there any way to accomplish this?

View 1 Replies

What Is The Class Attribute And How To Use

Nov 8, 2010

What is the class attribute and how to use

View 1 Replies

Why Value Is Available When Use Code Behind Attribute Add

Feb 18, 2010

I have a TextBox in my page

<asp:TextBox ID="TextBox1" runat="server" ReadOnly="true"></asp:TextBox>

I am not able to get the changed value ( I have attached a ajax calender with this textbox)

in code behind because it is readonly

I can do this using TextBox1.Attributes.Add("readonly", "readonly"); or I can get the correct last value using Request.Form[TextBox1.UniqueID]

Why value is available when use code behind attribute add

View 6 Replies

Add A Value - Less Attribute To A UserControl

Mar 29, 2011

In ASP.NET, you can add custom HTML tag attributes to a UserControl via

myLabel.Attributes['my-custom-attribute'] = "someValue";
// or Attributes.Add()

but how can I add an attribute that doesn't have a value? For example, (and I'm not saying that this is what I need) the W3C specification only needs the checked attribute present in a checkbox to consider it checked (instead of checked='true' or something).

<span ID="ctl-blah-blah-myLabel" my-custom-attribute>some text</span>

I'm looking into using something like this to tag specific elements on my page for some client-side behavior. I know that I can do the same with classes, but (1) classes are iffy to manipulate server-side, and (2) I kind of don't want to pollute my class declarations just for tagging (that may be weird for some, I know).

View 3 Replies

Web Forms :: Extracting Attribute Value From XML?

Jun 7, 2010

This may be something simple, but I am completely new to ASP.NET. I have been reading some tutorials based on W3Schools, and I have copied one of the files and tried to play with it by changing an element with a value to storing that same value in the attribute. Here is the edited XML (my.xml):

<?xml version="1.0" encoding="ISO-8859-1"?>
<countries>
<country>
<text value="N">Norway</text>
</country>
<country>
<text value="S">Sweden</text>
</country>
</countries>

I want to extract the N and S and use them as tooltips. Here is my aspx file:

<%@ Import Namespace="System.Data" %>
<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim mycdcatalog=New DataSet
my.ReadXml(MapPath("my.xml"))
my.DataSource=my
my.DataBind()
end if
end sub
</script>
<html>
<body>
form runat="server">
<asp:Repeater id="my" runat="server">
HeaderTemplate>
table border="1" width="100%">
<tr>
<th>Name</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td title="<%#Container.DataItem.("text").Attributes["value"]%><%#Container.DataItem("text")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>

What have I missed here?

View 6 Replies

Web Forms :: More Than One Attribute Allowed?

Jul 19, 2010

Why in asp.net web page we have only one FORM attribute, but in other language more than one FORM attribute is allowed.

View 3 Replies

XMLNode Add Attribute Without Prefix

Jan 26, 2011

I have the following method:

Code:

XmlNode AttributeNode = xmlDocument.CreateNode(XmlNodeType.Attribute, fieldName, WILTSNAMESPACE);
AttributeNode.Value = fieldValue;
parentNode.Attributes.SetNamedItem(AttributeNode);
this create (for example):
<Person d2p1:PersonRole="Boss">

How do I add an attribute without the d2p1: prefix:

<Person PersonRole="Boss">

View 5 Replies

Possible To Set AssociatedControlID Attribute Using JQuery

Apr 7, 2010

Is it possible to set "for"(AssociatedControlID) attribute using jQuery? I am trying something like this to set it to the very next control that appears after label:

$('label.asssociateClass').each(function()
{
var toAssociate = $(this).next(':input');
$(this).attr("for", toAssociate.attr("id"));
});

The problem is that if I don't set it on a server through AssociatedControlID it never gets here since it's rendered as span instead of label in that case. Is there a way to overcome this or I have to do it on a server?

View 2 Replies

MVC :: DataAnnotation Attribute For Integers?

Jan 11, 2011

Is there an out-of-the-box DataAnnotation attribute that checks if an integer is greater than a certain value?

public Model
{
[GreaterThan(0)]
public int MyVal{get;set;}

}

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved