how to Apply Master Pages By Folder in web.config - asp.net

I have folder called Email which contains 20 aspx pages I am trying to apply master page to this email folder through web.config
i Got following error
The relative virtual path 'MasterPage.Master' is not allowed here.
code in web.config
Please help in this issue

Use an application-relative path, like ~/Email/MasterPage.Master

Related

Admin page webmatrix i already have a *.cshtml file in root folder?

I am unable to see _admin page in Web Matrix. i already contain a *.cshtml file in root. Also my nuget package manager keeps on uninstalling itself please help me i am new with all this.
If you name a file with an underscore like _admin.cshtml, you will not be able to access it directly. You will however be able to navigate to it if you name it admin.cshtml.
Usually you will want to use underscores on the name when working with things like RenderPage or Layout pages: _Layout.cshtml.
This article has some helpful information on using Layout pages:
http://msdn.microsoft.com/en-us/magazine/gg983489.aspx

web.config file not there in the root(/) directory

I was trying to run a .cshtml file but it gave an error:
Server Error in '/' Application.
--------------------------------------------------------------------------------
This type of page is not served.
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
Requested URL: /index.cshtml
So I searched for the solution and found that I had to edit the web.config file which is in the root directory(here it is My Site), but there is no file like that there there is only an index.cshtml which I had created.
I searched even the IIS and the IIS Express folders in Programs Files\ but there was no file like that?
If you are using WebMatrix, maybe your mistake was the starting point choice.
If you want to create a new Web Pages site you must start from a template in the Template Gallery of WebMatrix. Pay attention that the Empty Site template differs from the Empty Site option outside the Template Gallery because the first holds the files (binaries, packages and the web.config too) that are needed.
As the server error suggests, .cshtml files are not served, the reason for this is because they are server-side files that make up your application, they are just one piece of a much bigger picture.
If you launched your web application in debug mode and the URL in the browser was something like http://localhost:2932/Views/Home/Index.cshtml, just drop the /Views/Home/Index.cshtml part of the URL.

running asp.net solution containing multiple projects in iis

I have an asp.net solution containing more than 1 projects which are inter-related and each project have different configurations in web.config file. The whole solution is kept in a folder, lets say 'X'. I want to run the solution in iis. For that, I have created a virtual path in iis of 'X', converted the folder 'X' to an application, and created a web.config file in the root folder that is 'X'.
When I am viewing one of the project' default page in browser, it shows an error of
Parser Error Message: Could not load type 'app1.SiteMaster'
I have already compiled the solution.
Please help... Am i missing some settings...
It sounds like the application can't find the master page. Assuming that your projects share the same master page, you probably need to update the path to the master page to the relative path from the root.

Setting folder default page in aspnet

My question is really simple. I have a Web application with multiple sub-folders and there's no Default.aspx page in any of these.
How do I set the default page in each of these folders so users can type /folder instead of /folder/login.aspx?
Can this be done through the web.config file?
Should I just rename the file in each folder to Default.aspx?
Thanks!
There is a default document section for web.config, and you can even put a web.config in each folder, and inside that config just have the default document set.
There's a Default Document icon in the IIS section of your websites configuration panel. Open that up and you can add login.aspx to the list.

How-to: Proper redirect with Relative URLs ASP.NET

I have an authentication script (CheckLogin.aspx), and if any of the credentials do not match my application will redirect (via Server.Transfer) to the access denied page (forbidden.aspx). Each time my script runs,it gets an InvalidOperationException: Failed to map the path '/forbidden.aspx'. Here is a mockup of my applications file structure:
<root>
..default.aspx
..forbidden.aspx
..<inc>
....scripts.js
..<auth>
....CheckLogin.aspx
As you can see, the CheckLogin.aspx page is in a folder inside the root, and the forbidden.aspx page is inside the root itself. The path I am telling my application to redirect to is /forbidden.aspx.
Sometimes you have to precede the page path with a tilde to indicate the root directory:
'~/forbidden.aspx'
Are you using "~/..." to make sure all your paths are relative?
By the way, you should just set up page access via Web.config, by using the <location> tags. That way you can have some sort of role-based access, without much custom code.

Resources