I have a MVC4 project in VS2012.
How can i debug the current open page in VS in the browser? When i select "current page" in project properties always the path with the Views folder is opened. The path should be without the Views folder.
When i select "specific page" and leave the textbox blank always the root directory is opened.
If you are using the MVC framework you are most likely using the routing system.
To specify your starting page you need to give your project the path you want to open and not the view name (and selecting "current page" doesn't work because Visual Studio has no idea what route can be used to display the view your are on).
You need to manually set the Specific Page in your project option (under the Web tab) to the path you want to use (let's say you want to call your home path, then just fill up the field with home).
Related
I have loaded Visual Studio 2017 in the last year, and when going to create a Razor project now, this creates an Account folder containing several files for user authentication. I do my own authentication in a database and don't need these files.
Now using the .NET Framework 4.5 these appear to be required, even though I don't use them.
Is there any way to remove this Account folder and OAuthWebSecurity files?
The Account folder is create only when you use the default authentication type ASP.NET has, one thing to do if you don't need it is not to create it in the first place.
If you don't want to create it
When creating a project in Visual studio make sure No Authentication is selected by clicking on the Change Authentication button
Select No Authentication option and click OK
Click OK again to create the project.
If you inherited a project that already has the Folder and you don't want to use them
You can delete the Account Controller and also remove anywhere it was invoked eg. in the Manage Controller
Remove IdentityConfig.cs file from ~/App_Start directory
Remove all the Views in the ~/Views/Account directory
Remove Account, Idnetity and Manage View Model files in ~/Models directory
Since you are implemeting your own authentication, you know what to do in the Startup_Auth.cs file
Build and ensure no errors
there might be other file you need to remove.
I have a webshop in ASP.MVC.
The solution consists of 2 projects - a web.frontend and a web.admin.
In web.admin, file upload is possible. These files should be accessible from the web.frontend to show in browser.
I have tried tons of different C# methods to various paths...
Please provide me a way to put shared files where the browser can access them too.
I've tried placing the files at the .sln root - but the browser gives me an error: Not allowed to load local resource.
So somehow, the files should be placed in the web.frontend wwwroot? from the web.admin project?
Your only choice here is using virtual directories. In full IIS, that's a pretty straight-forward affair. You simply add a virtual directory to the site in IIS and point it to the location on the filesystem to where these files are stored. Then, you reference the files using this virtual directory in your HTML. For example:
Foo
The same is required in development, but the procedure is a bit more circuitous with IIS Express, since there's no GUI management. To add a virtual directory to your project in IIS Express, you'll need to go to File > New > Web Site... in Visual Studio. Click the Browse... button, and then click on the Local IIS tab. Select the site for your project, and then click the icon at the top-right that looks like a yellow folder with a red asterisk. Type an alias name (this is what you'll use in your HTML) and then browse to the location of your files on the filesystem. Uncheck Create IIS application and then click OK. Then, click Cancel and Cancel again. You're not actually going to create a new website; it's just the only way to get to this area where you can add virtual directories. Rinse and repeat with your other project.
I have a Visual Studio 2010 project with a Master Page that works fine.
~/Site.Master
In the same project is a Folder with another directory structure that needs to use another Master Page.
/xr
Within this folder, I have included the Master Page for those files.
/xr/XR.Master
My Default.aspx file attempts to access this Master Page using the following include:
<%# Page Title="XR Project" Language="C#" MasterPageFile="~/xr/XR.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Test1.Default" %>
Debugging on my machine in localhost works fine, but whenever I deploy it and try to navigate to the Default page in the xr folder, I get
Parser Error Message: The file '/xr/xr/XR.Master' does not exist.
However, the Source Error returns Line 1 as I have shown above.
Here is what I tried:
I moved the XR.Master page into the root folder and changed all of the files in the xr folder to reference the XR Master Page using the following include:
I debugged and tested the code on my machine using localhost, and it worked fine.
I pushed it out to the remote website and got the new error:
Parser Error Message: The file '/xr/~/XR.Master' does not exist.
What am I doing wrong?
EDIT: I do not like posting a link to the page, but I will for a short time until this is resolved:
Projects
From there, you will see everything works well enough except for the link to XR1200.
Here's the best advice I can give ya without knowing too much about your project structure.
I'm hoping you are using VS2010 so that things will look the same for you as on my machine.
One easy way to get the path of your master page all figured out is to add a test web page from masterfile, the path will be preset for you and you can use that in your existing pages.
Here is my blogs project structure.
Right click the folder where you want to add the test page and click add new file.
Add a new web form using Master Page. This is just for testing.
Now locate your Masterpage and select it.
From here just find your newly added content page in your solution structure and check the code files for the path to your masterpage.
Once you've verified that your path is correct, if it still bombs once you publish it then you've got either an issue where not all of your projects are building properly, or you're files aren't being uploaded properly and that is going to end up being something that you may just have to find on your own. I still suggest blowing away anything in your pub folder on your server and trying a clean publish.
Hope this helps!
my guess is that the iis setup is different on the different machines. typically, you see something like this when you have one machine set up with the site itself as a website and another machine set up with the site itself as an application within a website (like the Default Website). it looks like you have addressed this possibility by using the ~ in the path, but perhaps the iis on which you are deploying does not have the site directory itself set up as either a website or an application, but is merely a subdirectory of a site. in that case, the ~ would refer to the website directory (perhaps named xr?) and the site is in a subdirectory of that named xr. if this is the case, the solution is probably to set up iis such that you have the application directory configured as an application on the server to which you are deploying.
I am developing a C# VS 2008 website, trying to add a Master file. I created a virtual directory in IIS housing the "Master" folder, containing the Master files.
Now how do I reference these files from my website in VS? One problem is I do not know where I need to publish this Master folder to. Other problem is I do not know how to reference this Master file in my aspx Page directive.
FYI, this master folder is physically located outside of c:\inetpub\ in a totally separate file location. Is this a problem?
I don't think you'll get away with using a virtual folder for that because any pages that refer to the master page will be in the same application space as the master page (remember that master pages are just user controls). You create child pages by using Visual Studio or Expression Web to select "create from master page"
I'm hit a problem when attempting to deploy a MVC app as a sub-application of an existing ASP.NET 3.5 app (non MVC). The error is:
The view 'index' or its master could not be found. The following locations were searched:
~/Views/employment/index.aspx
~/Views/employment/index.ascx
~/Views/Shared/index.aspx
~/Views/Shared/index.ascx
The application works fine when running inside of visual studio web developer express SP1 and also works when configured as the top level web site.
I'm developing under XP (IIS 6ish) so I've already configured the wildcard mappings etc. The MVC app is configured as a virtual folder directly underneath the root web site (http://localhost/ROHAS where ROHAS is the virtual folder pointing to my MVC solution). I've also tried adding routes in the global.asax.cs to compensate for the sub application's virtual path:
routes.MapRoute("NetPortal", // Route name<br>
"localhost/rohas/{controller}/{action}/{id}");
and also
routes.MapRoute("NetPortal", // Route name<br>
"rohas/{controller}/{action}/{id}");
I've even tried adding another virtual folder that just points to the Views folder in my MVC solution.
However, I still get the error detailed above.
You have to create a Virtual Directory in the website youre using the MVC project in, with the name 'Views', which points to the Views directory in your MVC project. Make sure to just create a VD with only 'Read' access in IIS Manager, and make also sure you do not have a Application for the VD.
(VD -> Properties -> Make sure the application section is greyed out)
It appears that your view file is missing. Your employmentController is attempting to return a view/partial view named index.aspx/index.ascx which cannot be found. You should place your view in the ~/Views/employment folder of your mvc.net application directory. Or it can be placed in the ~/Views/Shared/ folder
The error has nothing to do with your routing in your global.ascx file