StaticFileHandler not working at all with IIS 7.5, Windows 7, ASP.NET MVC4, VS2012 - asp.net-mvc-4

So I have an ASP.NET MVC4 page working in IIS:
Only issue is that the static content is not served... (css, js, ... files)
This is the check-list that I've already done:
Enable the "Static" component in the "Enable/Disable Windows Features" dialog inside Control Panel, underneath the IIS tree node.
Have a <add path="*.css" verb="GET" type="System.Web.StaticFileHandler" /> inside the <system.web><httpHandlers> tag of my web.config.
Have a <add name="CSS" path="*.css" verb="GET" type="System.Web.StaticFileHandler" preCondition="foo"/> inside the <system.webServer><handlers> tag of my web.config (foo being 'integratedMode' or 'ManagedHandler').
Adding the "Impersonate a Client AfterAuthentication" privilege to my user (http://support.microsoft.com/kb/821546).
Also tried adding entries in IIS directly, in the dialog "Module mappings". In fact #lex-li is telling me that this is not needed so long as I see the "*" mapping, which is this one:
And it still doesn't serve the f**g files (404). What else am I missing?
In the log file (C:\inetpub\logs\LogFiles\W3SVC2\u_ex140313.log) I can see:
2014-03-13 18:21:09 192.168.0.161 GET /Content/Site.css - 80 - 192.168.0.150 Mozilla/5.0+(X11;+Ubuntu;+Linux+x86_64;+rv:26.0)+Gecko/20100101+Firefox/26.0 404 0 0 15

Alright, it was a permissions problem!
First, for my ASP.NET site to work, I had to do this in the IIS administration app, some days ago:
Click on your website node.
In the right panel, click on the 'Basic Configuration...' link.
Click on the button "Connect as...".
Choose "Specific user", and chose one which has Administration privileges.
(I mention this, in case the above has some effects on the thing I had to do below.)
Now, to solve my issue, I had to change the permissions of my folder (where I had my website written in the disk: C:\Users\knocte\Documents\Visual Studio 2012\Projects\SolutionFoo\ProjectFoo).
Go to C:\Users\knocte\Documents\Visual Studio 2012\Projects\SolutionFoo
Right click on 'ProjectFoo' folder -> Properties -> Security.
Click the "Edit..." button.
Click the "Add..." button.
Write "IIS_IUSRS", click "Check names".
Click "Accept" many times.
Refresh the page in your browser, now static files should work.
(You might also find trouble with the Temporary ASP.NET Files system folder, in which case look here.)

Related

Reference.vb code debugging

When adding a reference to a web service, a Reference.vb file gets generated to make all the service's types available to the hosting project.
When I put a breakpoint in that file it never gets hit. How can I solve this?
If you're using VS2013 you can disable Just My Code in the debugging options.
https://msdn.microsoft.com/en-us/library/dn457346(v=vs.110).aspx
That will make VS ignore the DebuggerStepThroughAttribute that Stephan B mentions. If you're using older version of VS you can delete the attribute from the Reference.vb
See System.Diagnostics.DebuggerStepThroughAttribute for why it never gets hit. Right now I don't know how to tell the Debugger to halt anyway, ignoring the Attribute but you should be able to remove the Attribute from Reference.vb and start your Debug session without VS regenerating the file.
You can try the below steps;
Open the web service project and go to web services project's "My Project".
Go to Web tab.
Choose "Don't open a page. Wait for a request from an external application."
Choose "Use Local IIS Web Server"
Change Project URL: "http://localhost/YourWebService" to your service name.
Click on "Create Virtual Directory".
Set the breakpoint at desire location.
Debug Run the web services "F5".

How to enable SSL for IIS Express in VS2015

I feel like I must be missing something easy, but does anyone know how to enable SSL for IIS Express when using an ASPNET5 web project? The Project Properties Debug screen only shows a port, not a URL ("classic" web projects still allow you to specific https in the url)
Edit your applicationhost.config in [SOLUTION_DIR]\.vs\config
for exemple in the sites section :
<site name="YOUR SITE NAME" id="1">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="YOUR SITE PATH" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
</site>
You do this in a vNEXT project almost exactly the same as prior projects. Microsoft just moved the settings to the debug tab of the project properties.
Open the properties of the project
Select the debug tab on the left
Tic the checkbox for Enable SSL
If yout don't have the above option
Click the project root node in the explorer window, press F4 and adjust the following:
This can be done simply if you click on the project in the Solution Explorer the open the Properties and set the SSL Enabled to True.
Click on the project and press F4, it will show the same properties list as previous visual studio versions where you can set SSL to true.
It will look like this in VS 2015
None of the solutions above apply if you are doing .Net 4.5 MVC project with "on premise", aka, ADFS authentication. If so, you won't see a 'debug' tab (see image below). You won't see an "Enable SSL" toggle box. Everything is done automatically by the IDE as long as you select a port in the acceptable range. I used the port 44300 and VS configured the /.vs/config/applicationhost.config file automatically (see below). I think VS might automatically setup SSL with the other authentication types (OAuth, etc.), but I haven't tested it.

IIS 6.0 preventing "PUT" & "DELETE" method types on WCF 4.0 web service calls (403 Forbidden)

I am a developer trying to assist my server admin in figuring out how to get this issue corrected.
But I have an app that is using WCF 4.0 configure-less setup to make RESTful webservices calls. Everything works fine locally but when pushed to my server all PUT and DELETE requests return a 403 forbidden error.
After searching around I've been unable to find anything that seems to work, and I'm not sure if there is some logs that would help figure this out, I'm not a server guy and apparently neither is my "server guy". So any tips on where to point him or what might be causing this would be greatly appreciated.
You would need to add the verbs to the appropriate handler on IIS 6. The below links explain on how to achieve it.
Steps as below:
1. Right click the Virtual Directory in IIS
Select 'Properties'
Click 'Configuration...'
Search for .svc in the 'Application Extensions' list
Select '.svc' (if this is not present, then you need to add it by clicking Add and using the same path for the executable as is used for the .aspx extension)
Click 'Edit ...'
In the 'Verbs' list select 'All Verbs'
Links:
MSDN Forums
Setting Application mapping on IIS 6

WCF Test Clinet - Can't Edit Config File

We are currently experiencing an issue that requires the client endpoint configuration file to be modified but can't find a way to do this in the WCF test Client. Is there a way to modify the Config file in the WCF Test Client?
I have read that you should be able to right click and select edit but this option is not available.
Running Visual Studio 2008 (without SP1 - please don't ask why)
To edit the client config in WcfTestClient, right click on the Client Config below the listed service and select "Edit with SvcConfigEditor". Is the "Edit with SvcConfigEditor" greyed out or missing when you right click on Client Config?
Here is a link on more information about WcfTestClient for .Net 3.5: http://msdn.microsoft.com/en-us/library/bb552364(v=VS.90).aspx
Update
The "Edit with SvcConfigEditor" is added in SP1, but you can try the following to make manual changes:
From http://social.msdn.microsoft.com/forums/en-US/wcf/thread/dde72fbe-e741-48fd-a9e1-253800d5227a/ Herve Roggero suggested this:
Well, I was facing a similar challenge. There is a manual way to do this until the tool gets updated.
Start the client interface (WcfTestClient.exe) with the WCF Service HTTP
Expand the service and right-click on the Web.Config (do not double-click - this will load the config file)
Click on Copy Full Path
Go to the file and edit the configuration sections you need to change (buffer limits, dns identity for https...)
You can now start using the tool with a modified config file.
Unfortunately everytime you restart the tool a new config file gets generated in a different folder. So this is a manual step. Still it helped me test an HTTPS endpoint that required changing the config file.
Hope this helps

Deploy WCF REST 4.0 to XP IIS 5?

I am trying to deploy a simple "Hello World" .NET 4.0 REST-style WCF service on WinXP (IIS5). It works fine in Cassini.
I tried to adapt the info here to me:
http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx
but something is not clicking. Can anyone lend ideas or comments? Yes, I must stay with WinXP.
Thanks.
After a fair amount of struggling I was able to successfully deploy a WCF 4.0 REST web service on XP/IIS5. For the benefit of you and others in the same situation, here's what I did (let me know if you need more detail):
Using VS 2010, build a deployment
package for the project and then
install it on the target machine
(your web server). The following
link will show you how to do this: http://vishaljoshi.blogspot.com/2009/03/web-packaging-installing-web-packages.html
Make sure that your virtual directory in IIS is configured to use .NET 4 (right click on virtual directory > properties > ASP.NET tab > ASP.NET Version)
Configure your virtual directory to support extensionless requests (i.e. your REST API) by creating a wildcard mapping (right click on virtual directory > properties > configuration > mappings tab) with the following properties:
Executable: C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
Extension: .*
Check that file exists: unchecked
(Note: watch out for the bug that keeps the "OK" button on this dialog grayed out. To get around this just click in the executable textbox after entering your extension and the "OK" button should get enabled).
If you get an authentication error when accessing the service then turn off integrated authentication on the virtual directory. This should fix the problem if you have used the defaults in the generated web.config of your service. If you have explicitly modified the authentication mode then you will have to adapt accordingly.
Have you considered self-hosting your service instead of trying to use IIS. That will probably be easier to do than use IIS.
In case above steps dont work. There could be a problem with permissions on your App pool for that website / virtual directory , you can try to set that right and try it out.
You can refer this article for more help on this.
http://technicalwizardry.blogspot.in/2013/04/wcf-rest-service-hosted-on-iis-5.html#!/2013/04/wcf-rest-service-hosted-on-iis-5.html