Adding a Secure Matser page in Visual Studio - asp.net

Good Day
How do you add a secure master page into the secure folder in Visual Studio? Is it a normal master page? How does it differ from the normal masterpage?
I have tried the following: Added a folder in my main root as: Secure. Inside that folder I have added a new master page and I named it Secure.Master. Now this will be the master page for any user that is logged...
It that all there is to it? Is a secure master page(logged in users) any different in Code Behind or anything than normal master pages for public users?
Thank you

ASP.net Membership seems like a place for you to start reading about. It will allow you to secure sections of your site: http://www.asp.net/web-forms/tutorials/security
You may also want to look at: http://blog.osbornm.com/2010/07/21/using-simplemembership-with-asp.net-webpages/ for a more simplified implementation i.e. SimpleMemberhsip

Related

Creating a Simpler Home URL for ASP.Net Web Applications

Hopefully a simple question:
When creating a typical asp.net webforms app, the "real" home page url will be something like "https://example.com/myapp/index.aspx".
Of course, this looks like garbage in the user's web browser. Is there a simple way to have it appear as just "https://example.com"?
Is the solution a routing rule of some sort?
Thanks for any help,
-Pete
Well, you only see/have/get a sub folder, since that is where you sent/published the web site to.
So, if you publish to the root of the web site, then in theory, yes, you should be able to just type in the "base" URL of the site. In some cases, due to a "default" page setting, then when you type in:
www.zoo.com
It "might" say default to:
www.zoom.com/Default.aspx
now, of course we "often" setup what are called friendly URL's, and thus this will keep (hide) the aspx extension.
But, there should not be the sub folder you have, and that suggests/means that you published to a sub folder of your web site.

master page file issue

I am using SharePoint Server 2007 Enterprise with Windows Server 2008 Enterprise, and I am using publishing portal template. I have a root web site and some child sub-web site. I am using Blueband.master and related css files (e.g. Band.css).
My question is, for my parent site and child site, are they using the same master page files (including css files) or using different master page files (including css files) -- if they are using different ones, how to find which master page files (including css files) root site and child site are using? I ask this question is because I find some modifications of root web site does not apply to child site.
thanks in advance,
George
To find out which master page they are using you can iterate (programmatically through each site, and output it to the screen.
I HATE the way Sharepoint handles this. Normally each time you make changes to the root master page you need to re-force all the subsites to use the same master page - even if you have already done so. I ended up writing an httpmodule based on the link below to allow me to specify any master page I want - with the added effect of allowing me to style the much maligned application.master. With a little tweaking you can set up replace rules in the web.config to allow you to have different master pages for different subsites.
have a look at http://odetocode.com/articles/450.aspx

How to restrict ASP.NET permissions per page or per directory (code access security per page or per directory)

This is the scenario:
-Hosted web application.
-Application trust level is full trust, because of external components.
-Customer should be able to customize some web pages.
I thought about using an html template that they can modify. But it is not flexible enough.
For example if there is logic things get messy and difficult: if user is logged in render this way, if we are in that page render this part differently, etc, etc. I end up creating a new scripting language, customers won’t like it.
I would like to use an aspx page that they can modify. The problem is that they can write any code in the aspx page, access the file system, etc.
Questions:
-Is there a way in ASP.NET to restrict certain directory or web page permissions (i.e. code access security per page or per directory)?
-Any other suggestions for implementing secure customizable web pages?
Do not do this.
No matter what you do, there will be security issues. Give them a template only, and you process that yourself. As far as I'm concerned, a wiki markup like Markdown is quite acceptable.

ASP.NET webpages without names, like stackoverflow?

Mentioned stackoverflow only as an example, but if you look above the URL for ask is
http://stackoverflow.com/questions/ask
which means /ask is a subdirectory, but they also do this for the specific question pages. How do you code this in .NET?
Not a code question as much as a technique. I know this is great for SEO, but how do you create a site so that every "page" is its own directory? Dynamically.
Do you have a template or a hidden redirect???
How?? :)
It's termed URL rewriting:
Url Rewriting with ASP.NET
MSDN: URL Rewriting in ASP.NET
EDIT: As #Justice points out, StackOverflow uses Routing.
StackOverflow uses something called Routing, which comes with .NET 3.5 SP1. Routing is a popular feature of a number of MVC frameworks, such as ASP.NET MVC, Ruby on Rails, and a number of Python and PHP frameworks.
Stack Overflow was built using ASP.NET MVC which uses a technique called Routing, see:
What Was Stack Overflow Built With?
and Routing
Stack Overflow uses ASP.net MVC
MVC uses the URL + Query String to determine the content, so its not like a URL which points to a specific page, but more like a hierarchical path to the properties of some data to be displayed
E.G. https://stackoverflow.com/users/[Put User ID Here]/[Put User Name Here]
prompts the website to display a USER with an ID specified in the path ( in this case the user name is probably just for kicks ) as opposed to a specific page created just for that user.
I have seen this accomplished by simply creating a folder for every web page and then having each folder contain a Default.aspx document (Assuming Default.aspx is setup as a default document in IIS, which it is by default). Then you can navigate to any folder on the site without specifying the page (Default.aspx).
For the dynamic part, I have worked with CMS systems that do it this way and the Default.aspx page simply inherits from some master template and the CMS system utilizes the ASP.NET rendering enginge to dynamically complete the web page.
Using folders may be a little heavy with the site structure, but it is an easy way to eliminate the page names from the browser.
This is how I structure my website and avoid having to use page names... for example http://www.innovaapps.net/Blog simply brings up the default.aspx page without having to specify the page name.

How to consolidate ASP.NET master pages across applications?

First shot at throwing a question on these boards so hopefully I can get some help, here goes:
I am working to start up the .NET practice at my client. We have 5 small scale .NET applications in place currently with a few them of them live into production. They're mostly small reporting pieces with some data entry/business logic functionality. Each of these applications is currently using the identical master pages.
What I mean is that there is a copy of the same master page in each application. They are all basic website->WCF->BL->DB tiered applications. So I have 4 copies of the same master page that I have to change when I make a change to it.
The client DOES NOT want to consolidate all of these into a single solution. They like the separation of applications across sites. I just don't want to continue dealing with the hassle of multiple updates for common elements (which there will be many more of across these applications).
The code is all stored in team foundation server. We also do NOT want to compile the master page into a .dll and deploy it.
Can anyone please make some suggestions as to how I can maintain a single copy of these common files (master, .css, etc) across my multiple applications.
thanks in advance
You might want to look at Sharing Master Pages in Visual Studio.
If that is no help then you could try using Build Events in Visual Studio. I would pick one of the projects to be my "Main Project" and only edit the master page from that project. When you build the project it would run a command that would copy that master page(if it had changed) to your set locations.
The client DOES NOT want to
consolidate all of these into a single
solution. They like the separation of
applications across sites. I just dont
want to continue dealing with the
hassle of multiple updates for common
elements (which there will be many
more of across these applications).
The code is all stored in team
foundation server. We also do NOT want
to compile the master page into a dll
and deploy it.
You eliminated the only two real options there. What all is in the master page? Would it be possible to extract the HTML UI elements to a single template or series of template HTML files and import those dynamically into the master page? You could then relocate the common HTML to an arbitrary URL and have the master page for each application pull it in dynamically.
Edit: I lied. You could also use a VirtualPathProvider like Sharepoint does to store the master page in a database or some other directory, but beware that VirtualPathProviders do not work in MediumTrust environments.
See:
http://msdn.microsoft.com/en-us/library/system.web.hosting.virtualpathprovider.aspx
If you are using Web Applications (compiled into a dll) rather than Web Sites you can do the following:
Right click on the folder you want to store the master page in
Select "Add Existing Item..."
Browse to the master page on the file system, and select both the .master and the .master.cs files.
Then, rather than clicking on the "Add" button, click on the little down arrow to the right of Add, this will bring up a little menu with the options: "Add" and "Add As Link"
Select "Add As Link" this will reference the file in your project, while leaving it in the original location in your dev environment - this allows you to edit it in either application, while keeping it up to date in the other applications.
Obviously if you edit the code behind, you'll need to re-compile the other projects before you deploy the changes to those sites.
This isn't available in web site projects as they rely on the file structure to work out what is in the project.
EDIT: Missed the css part. Obviously you won't be able to serve those files, so this should only work for the master page.
Don't know your scenario, so
IF you can control the DNS / virtual directories to the applications you could use a format like this:
c:\inetpub\wwwroot\Application1
c:\inetpub\wwwroot\Application2
c:\inetpub\wwwroot\Application3
c:\inetpub\wwwroot\Application4
c:\inetpub\wwwroot\Application5
and have your Master page at c:\inetpub\wwwroot\master.Master,
c:\inetpub\wwwroot\master.Master.cs,
c:\inetpub\wwwroot\master.Master.cs.designer
Then you could reference the single copy of the master page from /../master.Master. I gave this a quick shot with a precompiled master page to make sure I could reach back beyond my root. You might have to give it a shot to see.
We use our source control to create links to the shared files in all the places that we need it. So if you edit in one place, you just need to do a get latest and it will appear in the other places you have linked it.
I ended up going with the VPP route. I created a virtual path provider and built my master page into a DLL and this is working. Now I have a massive problem though in that a Content page whos master page is late bound through the codebehind throws validation/formatting hissy fits because it thinks its should be a stand along page. my CNTRL + K, CNTRL + D has broken on every page where I'm now sharing my master page. This is extremely frustring for me and the team

Resources