I have a MVC website that has a custom permission system. When user calls a controller method I retrieve his permissions from the DB and store them in a object that I pass to view rendering.
In the view I render only some parts of the content (based on the permissions). I would like to add an output to the footer.
You have Permission1, Permission2 that are checked on this page. You
are missing Permission3.
Questions:
What is the appropriate http-request limited scope where I can keep a list of used permissions and add to it during the rendering?
Can I modify the finished HTML output after all the child actions are rendered?
2.1. I assume that this would be in the _Layout view after #RenderBody() is executed?
Related
Is it possible to have results from another page returned to a JavaScript method or a C# controller action?
I have a shared complex page that's used all over my website that's currently used to set a single variable on the user data in the C# back end. When the user has finished the shared complex page, I return to the referring page. The page that I've returned to contains the newly selected variable when the user returns as it's refreshed or alternatively passed as a url parameter to the returning page.
I have a new page where I'd like the variable from my shared complex page to be returned. However there will be multiple instances of this variable on the page and they're actually different data to the previously stored single variable on the user data in the C# back end. i.e. I'd like to have several buttons on the page that lead to my shared complex page and when the user returns the data for each button will be displayed next to the button.
Is there a way in JavaScript or C# to display another page and have the result returned to the method that instantiated the display of the page? If my back end was implemented in scheme I'd use a continuation to achieve this result. Is there any equivalent in C#? I've been looking at async tasks in C# but none of the examples show a user interacting with another page as part of the asynchronous operation. Is this possible?
If not I'll have to pass the value back to the new page via URL parameters. I would like to avoid this because of the amount of contextual data I'd need to pass between the two pages. I'd thought of using a redirect from the shared complex page to update the new data on the back end before returning to the new page to solve half the problem but this site works on mobile so the network latencies rule out redirects. Also having the complex shared page as a pop up dialog within the new page won't really work as it's a) complex b) the new page can be used a pop up on an existing page and having a pop up from a pop up is unsupported on Bootstrap.
The sharing of data between web pages, without an established continuation medium, requires the use of a shared state somewhere, like session variables or cookies. As each page changes the state, it can go back to the server, update that session, and when the process is done, you'd read that session via ajax and complete your process.
I am developing an application in asp.net using c#. In my application there are two pages like abc.aspx and xyz.aspx. I am opening the xyz.aspx page in an iframe of abc.aspx.
In xyz.aspx page I have a asp hidden field named ht_test_access. Now my requirement is I have to access the value of that hidden field from abc.aspx directly without querystring, session, cookies etc. Please help.
You can use Button.PostBackUrl and use Page.PreviousPage to get the previous page form data. This MSDN article Cross-Page Posting in ASP.NET Web Pages explains it very well.
string text = ((HiddenField)PreviousPage.FindControl("hdnField")).Value;
Cross-page posting is similar to hyperlinks in that the transfer is
initiated by a user action. However, in cross-page posting, the target
page is invoked using an HTTP POST command, which sends the values of
controls on the source page to the target page. In addition, if the
source and target page are in the same Web application, the target
page can access public properties of the source page. As always, all
of the pages in the application can share information stored in
session state or application state.
I have a web application using Enterprise Web Library and I've found the need to have a custom log-in page. I see that EWL provides one for me, but I want to be able to have some custom elements on the page and control how the user is logged in. How can I achieve this in EWL?
First, create your custom log-in page. Let's call it MyLogIn.aspx.
The next step is to designate MyLogIn as the log-in page for some/all of the pages and shortcut URLs in your app. To do that for pages, override PageInfo.LogInPage and/or EntitySetupInfo.LogInPage and return a MyLogIn.Info reference. This setting is inherited from parent pages and entity setups. If you want all pages in your app to use MyLogIn, you only need to override the LogInPage property at the root of your page tree.
To use MyLogIn for your shortcut URLs, use the logInPageGetter optional parameter in the ShortcutUrlResolver constructor. Pass a function that returns a MyLogIn.Info reference.
The final step is to implement MyLogIn. You can design the page however you want and collect whatever credentials you want, but there are a few things you need, which depend on whether you still want to use EWL's UserManagement subsystem. If you do, you need to call UserManagementStatics.SetUpClientSideLogicForLogInPostBack during LoadData and call either UserManagementStatics.LogInUser or UserManagementStatics.LogInSpecifiedUser from a DataModification. If you are not using UserManagement, you're responsible for authenticating the user in your own fashion as part of a DataModification, before redirecting the user into the app.
Nearly every page of our application has several filters on it. My current goal is to implement a mechanism to store the filters and preselect them when a user re-opens a page, so at least during one session user don't have select them over and over again when he's opening a page, or moving from page to page.
The application is written with ASP.NEt MVC and we use a lot of javascript to handle filtering. At the moment a lot of filtering is done only on the client side(for example, the complete data for the grid is retrieved and all further filtering is made only on the client).
I was thinking of these steps:
Base class for the controllers: Method1 takes data send by the method from the common.js and saves it in the Session.
common JS: to common.js add a method, which accepts a selection made by a user, and together with the name of the control and name of the page sends it to the server Method1 in order to store new selection in the Session object.
Base class for the controllers: Method2 accepts name of the controller, name of the page and retrieves Session object.
JS of individual pages: in the onload event specifying all existing filters and getting data from the Method2.
However, I'm not sure that this solution is universal and optimal.
And I don't want to reinvent the wheel. Is there any already existing solutions or patterns for this task? Or any ideas how this can be done better?
One of the way that comes to my mind is using of Cookies rather than the session as it just the section and you can read the cookies from the JavaScript itself. it will save the server resource as you will not save anything in the Session. If your selection criteria is not very sensitive , there should not be any security issue
I have users, they are signing in system. They have developed pages (using edit button and then press save button) but this is my CMS pages. I want to copy my single pages user by user to publish them. How to create dynamic aspx pages, with config files etc? How to add domain folder?
Generally there's no need to create aspx page or static html pages per user. What you need to do is store his/her post body and other necessary info in db and then create a main page to place user-specific data (like post body, posted-by,..) on it.
For example, you may have a route like this:
/post.aspx?userId=1
This page pulls data from database for the user of Id=1.