I am writing a Federated web solution it has multiple projects. Debugging has been working fine until yesterday when suddenly (I don't recall messing with anything critical) I got the 'breakpoint will not currently be hit. No symbols have been loaded for this document' message on my 3 ASP.MVC projects in the solution.
I trawled around the web and this site for advice and these are the things I have done.
checked build > configuration manager for correct build setting
checked project > properties to ensure ASP.Net ticked for debuggers
checked Web.config to ensure 'compilation debug="true" targetFramework="4.0"'
iisreset
deleted bin & obj directories in each project
clean and rebuild the solution
deleted the contents of
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files'
exited and restarted VS2010
cried like a baby
After doing these things 2 of the 3 ASP.MVC projects are debugging properly, but the 3rd and critically the one I actually want to step through is not.
other info for you
using locally install IIS (not IIS express)
Windows 7
VS2010 with all service packs
ReSharper is installed
Chrome is the Browser I'm using
Any help appreciated.
This may be obvious, but it wasn't in your list of things you've done and in a state of panic can get forgotten, but have you checked the the Directory in IIS is the same as the one the code VS has loaded?
VS should recreate the site (depending on project settings), so try closing VS, deleting the site, reopening the project and letting VS recreate the IIS site for you.
I have worked out what the problem is.
While I had the initial problem of all projects not debugging the federation project turned out to be a special case. I have been away on leave and had forgotten that I had this in my web config
<federatedAuthentication>
<!--
<wsFederation passiveRedirectEnabled="false" issuer="https://localhost/FederationProvider/"
realm="https://localhost/Application/Home/FederationResult" requireHttps="true" />
-->
<wsFederation passiveRedirectEnabled="false" issuer="https://localhost/Issuer/"
realm="https://localhost/Application/Home/FederationResult" requireHttps="true" />
<cookieHandler requireSsl="true" path="/Application/" />
</federatedAuthentication>
When I changed it so I am using the federator rather than the issuer directly the debugger works.
<federatedAuthentication>
<wsFederation passiveRedirectEnabled="false" issuer="https://localhost/FederationProvider/"
realm="https://localhost/Application/Home/FederationResult" requireHttps="true" />
<!--
<wsFederation passiveRedirectEnabled="false" issuer="https://localhost/Issuer/"
realm="https://localhost/Application/Home/FederationResult" requireHttps="true" />
-->
<cookieHandler requireSsl="true" path="/Application/" />
</federatedAuthentication>
I feel pretty stupid for not realising this earlier. VS2010 was just being too smart.
Related
I have installed Windows 8.1 pro and moved all MVC projects to new work-space using VS 2013 Community Edition. All projects were using code first migration.
Database Publishing was also done using code first migration. All was running fine before I updated my machine.
But Now when I publish web application to remote servers, 'Publish Web' dialog box not showing "Execute Code first Migration", Instead its showing "Update database" for updating database.
And when I close it, It modifies the publish files for DB First. It seems that some global setting enforcing it to the following code:
<Objects xmlns="">
<ObjectGroup Name="DefaultConnection" Order="1" Enabled="False">
<Destination Path="" />
<Object Type="DbDacFx">
<PreSource Path="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MVC-20140923125211.mdf;Initial Catalog=MVC-20140923125211;Integrated Security=True" includeData="False" />
<Source Path="$(IntermediateOutputPath)AutoScripts\DefaultConnection_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />
</Object>
<UpdateFrom Type="Web.Config">
<Source MatchValue="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MVC-20140923125211.mdf;Initial Catalog=aspnet-MVC-20140923125211;Integrated Security=True" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />
</UpdateFrom>
</ObjectGroup>
</Objects>
Its strange why "Execute Code first Migration" is not shown for all my projects.
This behavior is same for all my other projects too.
The App_Data databases also not opening. So I changed connectionString' datasource from Data Source=(LocalDb)\v11.0 to Data Source=(LocalDb)\MSSQLLocalDB (MSSQL Sever 2014 express). Changing DataSource worked for opening database though.
I tried the solutions:
Tried this : "Execute Code First Migrations" checkbox disappeared from my publish profile
Enable Migration -Force
Clean, Rebuild and restart project and
Visual Studio.
Delete and re-import publish file
I tried solutions above few months back. That time the points above worked but now nothing works.
Is there any solution available for this? I wasted my whole day and still not found solution.
You need to install the Visual Studio update 4. Go to Extensions and updates under tools.
You might find this helpful:
Entity Framework Code First Data Migrations not working with VS2012 Web Deploy
I myself am still trying to find a simple way to deal with migrations.
I found a temporary solution for this. Manually replacing all ConnectionString name (Defaultconnection) to context name "ApplicationDbContext" without namespaces solved the problem.
I am trying to deploy a MVC 4 application to IIS 8 on Windows Server 2012.
I am copying the files to the server by using Publish > File System.
I have created a new web site in IIS on the server, pointed this to the correct directory, but when trying to view the site I see 'This page can’t be displayed'.
I have never deployed an MVC application before, so may have missed something very simple.
After spending a lot of time searching on the Web, I have:
Ensured the correct version of .NET (4.0) is installed, and is selected within a new Application Pool created specifically for my app
Disabled Directory Browsing
Ensured the System.Web.MVC.dll is copied into the Bin folder
Added the following to web.config:
Below:
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="managedHandler" />
</modules>
I am very grateful for any help or suggestions!
Martin
Oh dear...it looks like the problem was caused by my using Port 110 in the web site bindings. I think this is a reserved Port.
Hope some of the bullets above help someone else anyway.
Developing an ASp.NET MVC 5 application. Runs without an issue on the development machine (Windows 7 x86). When I tried to deploy it on IIS 7.5 (Win Server 2008 R2 64 bit) I got 3 errors:
Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.
I fixed this issue by removing targetFramework="4.5" from
<compilation debug="true" targetFramework="4.5">
The tag contains an invalid value for the 'culture' attribute.
I don't know why but compliant was about the following entry:
<globalization enableClientBasedCulture="true" culture="az-Latn" uiCulture="az-Latn" />
After removing culture="az-Latn" uiCulture="az-Latn" this problem also got solved. But I don't think this is a proper way of solving that, so it'd be good to know the right solution.
Now the third error is the one that's taken all my day. After solving the above two problems now I get the error in the image:
The best solution that seems to work for almost everybody is to add the following entry:
<modules runAllManagedModulesForAllRequests="true" />
But I already have it in the config file. IIS was missing URLRewrite module so I installed it manually.(Don't know if this has anything to do with it though). Didn't help. Enabled 32 bit Applications. Didn't help. What else should I try?
There are two possible solutions
Make sure the application pool that is running your site is set to version 4. It's likely defaulted to v2 which will give you all the errors you mentioned in the question.
Re-register your framework with this command:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -i
I'd also revert those changes you have made (e.g. put the targetFramework attribute back in)
I've created Internet MVC Application with Individual User Accounts Authentication, but now this project should be intranet with windows authentication... How to switch authentication, when project is almost done? I'm not guru in MVC and this is new technology for me, so any help please and if possible with all steps in description=)
In the Web.config of you project. The first step would be change:
<authentication mode="Forms">
</authentication>
to
<authentication mode="Windows">
</authentication>
Selecting your project and hitting F4 for the properties window allows you to change the authentication method.
However instead of me putting step by step in here just use this very easy to follow tutorial:
Enabling Windows Authentication
Since I found this question through google attempting the same thing, and Firearm's link doesn't quite do the process justice, I'll attempt to list the steps I went through here. Obviously, if I tell you to remove something, that only means if you aren't using it otherwise. I don't think you have to do these steps in any particular order.
Also, I'm using Entity Framework, so you'll have to look elsewhere to remove it.
in the solution explorer, highlight your project and press f4. This will bring up the properties window for that project. Disable anonymous authentication. Enable windows authentication.
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution... uninstall anything with "owin" in the name, Microsoft.AspNet.Identity.EntityFramework, and Microsoft.AspNet.Identity.Core.
Open your Web.config. Under runtime, under assemblyBinding, remove all the dependentAssembly's for Owin stuff that got left behind. Under system.web, replace <authentication mode="None" /> with <authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>. Under system.webServer, remove handlers. under modules, remove <remove name="FormsAuthentication" />.
Remove the Account and Manage controllers and views. Remove the ManageViewModels from your models.
Under App_Start, get rid of IdentityConfig and Startup.Auth.
At the top level, right next to your web config, is Startup.cs. Get rid of it.
Make a new ApplicationDbContext. It should derive from DbContext. Get rid of throwIfV1Schema: false in your constructors. Then you can get rid of IdentityModels from your Models folder. Add a new migration and update your database.
Obviously you'll have to clean out any references you've made yourself to Identity.
Possible additional step:
* remove _LoginPartial view. The _Layout view will then be updated to replace partial display of that view with this line:
<p class="nav navbar-text navbar-right">Hello, #User.Identity.Name!</p>
Searching the exact same problem led me to this article, however the answers are a bit old, so with ASP.NET using MVC 5 this should be detailed documentation from Microsoft:
To detect Windows Authentication in an MVC project, the wizard looks for the authentication element from your web.config file.
<configuration>
<system.web>
<authentication mode="Windows" />
</system.web>
</configuration>
To detect Windows Authentication in a Web API project, the wizard looks for the IISExpressWindowsAuthentication element from your project's .csproj file:
<Project>
<PropertyGroup>
<IISExpressWindowsAuthentication>enabled
</IISExpressWindowsAuthentication>
</PropertyGroup>
</Project>
Found at Diagnosing errors with the Azure Active Directory Connection Wizard
For my specific problem it was switching to Azure AD rather than Windows Authentication (which was preset), there are more steps found at the developer network website.
I'm afraid I'm a bit late with my answer to you're question on how to implement the SwitchUser functionality, but for those of you who are still struggling with this (even Microsoft SharePoint still can't get it to work...), here's how it's done: (I just finished writing the article)
Switch User Functionality using MVC4 and Windows Authentication
If you need more information on how to get Windows Authentication workong for an Intranet Website using AD and Windows Server 2012 (or Higher), then take a look at my following article:
Windows Authentication on Intranet Website using AD and Windows Server 2012 (or Higher)
Happy coding!
I have an IIS7.5 web-site, on Windows Server 2008, with an ASP.NET MVC2 web-site deployed to it. The website was built in Visual Studio 2008, targeting .NET 3.5, and IIS 5.1 has been successfully configured to run it as well, for local testing.
However, whenever I try and navigate to a page running in IIS7, I get a 404 error.
I have checked the following things:
There is no corresponding 404 log entry in IIS logs.
Actually, there are 404 entries in the IIS log.
The application pool for the web-site is set to use the Integrated pipeline.
The "customErrors" mode is set to off.
.NET 3.5 SP1 is installed
ASP.NET MVC 2 is installed
I've used MVC Diagnostics to confirm all MVC DLLs are being found.
ASP.NET is enabled in IIS, which we've demonstrated by running the MVC Diagnostics page.
KB 2023146 did highlight that HTTP Redirection was off, so we've turned it on, but no joy.
EDIT
Ok, so we've installed the world's simplest MVC application (the one which is created when you create a new MVC2 project in Visual Studio), and we are still getting 404s on any page we try and access - e.g.
<my_server>/Home/About will generate a 404.
Any ideas will be greatly appreciated!
This is quite often caused by the following missing from the web.config:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
Do you have a problem with just 1 page or the whole site is not working?
A) 1 page
You can use RouteDebugger to verify if the route is matched correctly
B) Whole site
I assume you're using Windows Server - check if ASP.NET is enabled in IIS - it's disabled by default, I believe.
You can use MvcDiagnostics page to check if all dlls are deployed properly.
Are you running in IIS7 integrated mode? Classic mode of IIS7 does not automatically map extensionless URLs to ASP.NET (much like IIS6)
Make sure your Web.config tag is configured correctly.
We finally nailed this issue by exporting the IIS configuration of a working server, and comparing it to ours.
It was a really obscure setting which had been changed from the default.
IIS ROOT → request Filtering → Filename Extensions Tab → Edit Feature Settings → Allow unlisted file name extensions
This should be ticked.
This can be set at the IIS level, or the site-level.
Glad that fixed your problem. Others researching this issue should take note of the extensionless URL hotfix: http://support.microsoft.com/kb/980368
If none of the other solutions here solved your issue, check that you have the
Global.asax
file in your website. This solved the issue for me.
Checkout if KB 2023146 applies to your scenario. Also try requesting directly a controller action: /yoursitename/home/index
Apparently this can have many different causes.
For us, the problem was that the DNS entry was configured for two IP addresses, but the IIS configuration would only listen to one of them. So we got unpredictable results, sometimes it would work, sometimes a few files (css, etc) would not load, and sometimes the whole page would not load.
For me it was all about installing .NET Framework 4.6.1 on the server (my app was targeting that version)
You'll also get this if your bindings aren't correct. If you don't have www or a subdomain it'll return a 404.
I had this problem when running my MVC4 site with an app pool set to ASP.NET 4.0 and the Classic pipeline, even though the extension handlers were set in my web.config and were showing correctly in IIS. The site worked in Integrated Pipeline so I knew it was a configuration issue, but I couldn't nail it down. I finally found that ASP.NET 4 was disabled for the server in the ISAPI and CGI Restrictions settings. I enabled ASP.NET 4.0 and it worked.
In addition to checking if you're running in integrated pipeline mode, make sure your application pool is set to use .NET! I recently ran into this problem, and when I went in to check the app pool settings, I found that somehow it had been set to "No Managed Code." Whoops!
My Hosting company fixed this for me by doing this (I removed the original password value of course).
<system.webServer>
<security>
<authentication>
<anonymousAuthentication password="<password>" />
</authentication>
</security>
</system.webServer>
Typically I encounter this issue when there is a Routing problem. I compare a working vs non-working to resolve it.
Today however I accidentially created a Virtual Directory in IIS.
It has to be an Application, right click on the Virtual Directory (with a folder icon) -> Convert to Application:
Don't use runAllManagedModulesForAllRequests. You want to let IIS handle resources such as images.
<system.webServer> <!-- Rather do NOT use this -->
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Instead add the MVC routing module
<system.webServer>
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
</system.webServer>