My question is almost similar to this
ASP.Net Roles: Page-Level Security Question
except for the fact that I'm not using asp.net membership, What I have done is I have created roles and assigned pages to roles, menus are also populating according to the user's role. I want to restrict user to access pages by simply typing the PageName.aspx , One solution might be checking on every page load, but I don't think it's efficient. I have googled but only found solutions for adding <location path="Logon.aspx"> to restrict, I have to add this for every page in web.config, which defeats the whole purpose of keeping this thing dynamic, I am using Form Authentication, Some are suggesting creating a Base Class and derive other pages from that class, I think there may be some global.asax way to acheive this, but have no idea. Please suggest me best approach to achieve this !
P.S : I am not using ASP.NET Membership
legendinmaking,
This is depend on your project layout . One solution is that you create a folder structure where you place webconfig and there you give permission for the user i think this may be one solution and may be others.
finally, what I did is I checked access of Pages for every user on MasterPage's Page_Load using a method name IsPageAssignedToRole() to check
string requestedPage = Request.Url.Segments[Request.Url.Segments.Length-1];
if (requestedPage != "UnAuthorized.aspx")
{
AdminUserAuthInfo au = (AdminUserAuthInfo)Context.Items["AdminUserAuthInfo"];
int current_role= int.Parse(au.Roles[0].ToString());
if (!AdminRole.IsPageAssignedToRole(current_role, requestedPage))
{ Response.Redirect("UnAuthorized.aspx",true); }
}
Related
Please this simple scenario:
#Chrome
Scenario: Simple Calculation
Given user
When User login to the system
And ....
So i have many scenarios, each scenario use default Browser or specific one (in this example the Browser is Chrome)
So i have several URLs than i am checking so i looking for way to define global Tag what will represent URL and inside .cs file this Tag will converted into my URL (and as i mentioned before i have several).
And i want to use it this way:
#GlobalURL
#Chrome
Scenario: Simple Calculation
Given user
When User login to the 'GlobalURL'
And ....
Any suggestion ?
If you want to use #GlobalURL tag for scenarios, then you can add method with annotation: [BeforeScenario] and in this method get that hook, and depending on it's value get correct url. In my project I made a separate class - TestConfiguration, which properties (base url, key, what kind of test) and filled from tags before every scenario, and then used in test.
Also you can in scenario send parameter and based on it choose url in the code.
I am damn confuse in TabId and ModuleId which need to pass as parameters in Globals.NavigateURL.
I have created a project with 2 UserControl. Now I want to navigate in button click event of first UserControl.
I have reviewed some reference. Most of them suggest to pass TabId, Key and ModuleId. I know Key but I don't know what is TabId and ModuleId and how to get it in my .cs file of usercontrol.
Can anybody please suggest me?
If your module is set up correctly, these should be available to you as they are inherited.
From your question it seems you don't know enough about the framework. I recommend that you get a copy of the DNN 7 book. It's relevant to DNN 8, and should start you off correctly. There are other things available: the wiki and the developer resources there.
In answering your other question, I told you that the following two lines of code are equivalent:
string miUrl = base.EditUrl("ModuleInfo");
string miUrl = DotNetNuke.Common.Globals.NavigateURL(base.TabId, "ModuleInfo", String.Format("mid={0}", base.ModuleId));
If you inherit from PortalModuleBase, you have access to TabId and ModuleId in the base class. If you only need to navigate to a module control (view) in the same module, base.EditUrl() works fine. You need to use NavigateUrl() if you need to navigate to another module or to another page (tab).
I looking ways to redirect the page from the server side code and pass couple variables into the new page ( i can pass the same data through query string or session but i dont want to do that) what is the best way to do this?
Thanks in advance!!!
You have a few options:
QueryStrings (you don't want to use this)
ASP.Net Session (you don't want to use this)
Multiple hidden forms with variables (http://msdn.microsoft.com/en-au/magazine/cc164151.aspx)
Using the Button PostBackUrl attribute.
Expose page properties/variables as public - dirty.
ASP.Net Cache
NCache (http://www.alachisoft.com/ncache/)
Server.TransferRequest (http://msdn.microsoft.com/en-us/library/aa344901.aspx)
. Can handle any additional headers you place inside the request (post data).
I'm very new to Selenium RC. I'm using .NET (though I don't think it is relevant), I have opened a page, but I want to confirm that the page was actually opened. I have a few ideas like using .Select() or using one of the .get*() methods, but I want to do what is considered the best practice by others in the Selenium community.
I usually assert some text or element on the page. You most likely don't just want to make sure the page "loaded" you want to make sure it loaded something specific
I am currently confirming the page was returned using the following:
[Then(#"the (.*) page should be displayed")]
public void ThenThePageShouldBeDisplayed(string pageName) {
Assert.IsTrue(selenium.GetLocation().Contains(pageName));
}
This happens to be a SpecFlow test step implementation.
My typical application has a couple of textboxes, checkbuttons, radiobuttons, and so. I always want to load the settings the user used the last time when the program starts, and also want to save the settings as the users clicks "Save settings" or closes the application. When the user attempts to save the settings, I'll have to check each of the controls for input errors (sometimes they have to have a max length, other times only caps, other times other things, there isn't a rule for them all, everytime it'll be different), and only if everything's OK i'll let him save the options. If there is something wrong, no option is saved and my errorcontrol provider will pop up a description of the input type info that should be put in that control.
I've been designing this from scratch for all my projects, but it's being a pain to do it. So I'd thought maybe now was the time to do some library to help me. I thought initially that maybe it'd be a good idea to have all the controls on my form that are going to be part of this save/load process to have an attribute associated with them, something like this
public delegate bool InputIsOkHandler();
public class OptionsAttribute : Attribute {
public Control controlRef;
public InputIsOkHandler IsInputOk;
public string errorMessageToShowOnErrorProvider;
public OptionsAttribute(Control controlRef, InputIsOkHandler inputHandler, string errMessage) {
...
}
}
The main problem here is that when I declare the attribute on a given var:
[Options(...)]
TextBox textBox1 = new TextBox();
I'll get
Error 1 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type.
So I guess this approach isn't the best one. What would you guys do in this situation? Would you use attributes? Would you use other mechanisms?
Thanks
Do you know that .NET already includes such a system since 2.0? See MSDN, CodeProject and this white paper from WestWind.
The Personalization and User Profiles supported in ASP.NET 2.0 can be a nice way to achieve your goal.
You can check this MSDN article for a overview Personalization in ASP.NET 2.0