How can I achieve a binding redirect in asp.net vnext? Before I would have configured the bindingRedirect using xml in the web.config file, but I can find how to to this in the Project.json
https://github.com/aspnet/Home/wiki/Project.json-file
Binding redirects are not needed in ASP.NET 5. The loader in ASP.NET 5 will automatically load the correct DLL based on project references and the available NuGet and project references.
Or, if you have a case that doesn't work, please provide more details.
According to David Fowler from the ASPNET team, binding redirects are gone and not coming back. I created a GitHub issue and he thinks this needs to be done at the Roslyn level (basically, don't output this warning anymore).
https://github.com/aspnet/Home/issues/407
Related
Rather than requiring Web.config, ASP .NET 5 provides a number of options to provide configuration data. Info on this can be found at:
Introducing ASP .NET 5 by Scott Guthrie
How can we store configuration data in new asp.net vnext? (StackOverflow)
ASP.NET vNext Moving Parts: IConfiguration by Louis DeJardin
There's an interesting question in the comments section of ScottGu's article:
The config.json file in the example, how is that protected by the webserver/http server? web.config is protected by IIS, but if any file can be used (which is great), it also comes with the burden that the webserver shouldn't serve the file out if one requests it in a URL. Or are there prefab names to choose from?
Can anyone answer this?
In previous versions of ASP.NET root of the project was also a root for the website. Some mechanisms were created to prevent access to files which should not be accessible to the outside world (like a whitelist of mime types, RequestFilteringModule).
This changed in ASP.NET 5 as a website root is no longer a project root.
Website root folder is a subfolder in your project directory (named wwwroot by default, but can be changed in project.json).
This means that everything outside a website root folder is not accessible to the outside world.
config.json file is outside of wwwroot so it won't be ever handled by any requests.
I have an MVC4 project with the template Intranet Application. Glimpse is working on the MVC4 Routes but not on web api routes (the footer vanishes).
I'm thinking of creating an action in a MVCController which takes a request as parameters to instanciate the right WebApiController and calls the right action with the parameters.
Is there a better alternative ?
I tried to use this (found here) but it doesn't work :
<inspectors>
<ignoredTypes>
<add type="Glimpse.AspNet.Inspector.RoutesInspector, Glimpse.AspNet"/>
</ignoredTypes>
</inspectors>
</glimpse>
The issue you mention is related to Glimpse making changes to the Routes configuration which broke the WebApi Help Pages, fortunately that issue has been solved in the meanwhile.
Based on your question, I assume that you want to see Glimpse diagnostics for WebApi related calls? Unfortunately Glimpse v1.8.4 does not support WebApi requests.
The good news is that support for WebApi is being added as we speak. You can check the pull request to see how it's going and when it's expected to be released.
I have a Web Forms app that I created a few months ago and I added a Web API controller. I tried to use the 'automatic' routing that I saw in a presentation recently, but all I got was a 404. Then I tried to add routing for the Web API controller in my Global.asax using MapHttpRoute, as I've seen in several tutorials. However, even after adding Imports System.Web.Http to the file, the project will not recognize RouteTable.Routes.MapHttpRoute() I have tried adding other namespaces and ensuring that I have all the necessary Nuget packages, but I still am unable to set up routing for the Web API controller. Does anyone have a recommendation of where to start?
If anyone has this same issue in C# read on.
I am also using a web forms app and set the routing through the Global.asax file. For me Intellisense was 100% correct and it would not build regardless. To get this to work I had to add the following using directives.
using System.Web.Http;
and
using System.Web.Routing;
Becareful not to use using System.Web.Http.Routing by accident. This wont work.
You should add the reference to System.Web.Http.WebHost assembly and make sure you have
using System.Web.Http;
Why ? MapHttpRoute is defined in two assemblies, in System.Web.Http:
public static System.Web.Http.Routing.IHttpRoute MapHttpRoute(
this System.Web.Http.HttpRouteCollection routes, string name, string routeTemplate)
Member of System.Web.Http.HttpRouteCollectionExtensions
and in System.Web.Http.WebHost
public static Route MapHttpRoute(
this RouteCollection routes, string name, string routeTemplate, object defaults);
First one is an Extension on HttpRouteCollection
Second one is an Extension on RouteCollection
So when you have a webforms app, your Routes are defined in a RouteCollection so you need the WebHost version.
Its because architecture allowing WebApi to be hosted also out of IIS. see Hosting WebApi
I found this thread, which indicates that IntelliSense apparently has a problem with this, but if you type something like the following, it will build and run:
RouteTable.Routes.MapHttpRoute("MyApi", "api/{controller}")
I've just created two new webforms apps (one using .NET 4, the other 4.5), did nothing more than add web api via nuget and it worked.
What version of ASP.NET is your app running in? If you're running ASP.NET WebForms 2.0/3.5 then it's not supported.
Here's a tutorial which demonstrates how to add Web API to your Web Forms app - http://www.asp.net/web-api/overview/creating-web-apis/using-web-api-with-aspnet-web-forms
I have the same case, I solved by creating the api controller, when you add the
api controller VS will load all required refrences.
Does anyone know if you still need the sf404.aspx mapping for Sitefinity 4.4?
I'm trying to run a new test SF 4.4 project, but when I try and login the page just gives me the following:
HTTP 404 cannot find /sf404.aspx (this was mapped like that for Sitefinity 3.7)
I then changed the IIS 404 configuration from sf404 to default and now I just get HTTP/1.1 404 Object Not Found.
The project works through Cassini, but not through IIS 6.
Any ideas?
Regards,
Jacques
the sf404.aspx page is definitely only used for Sitefinity 3.x and should not be mapped in a Sitefinty 4 website.
If you are attempting to run a newer version of Sitefinity on IIS6, you need to make sure to use a wildcard mapping so that all requests go through the ASP.NET engine.
This page details everything you need to setup to run Sitefinity on IIS6: http://www.sitefinity.com/documentation/documentationarticles/installation-and-administration-guide/install-sitefinity/configuring-the-iis-to-host-sitefinity-projects
You might also find this blog post helpful: http://www.sitefinity.com/blogs/joshmorales/posts/11-02-23/installing_sitefinity_4_on_iis_6.aspx
I have been working on a classic .Net web forms (4.0 framework) solution for my current project. Since the project is too big to upgrade to MVC, I simply added a MVC project to the solution and created all my REST services in the MVC controllers.
It was working fine for several days and randomly I started getting redirected to Accounts.Login?{ReturnUrl}. My web forms app doesn't have an Account folder the logical conclusion was that the MVC project was interfering somehow.
After checking all the configs, IIS settings, and debugging from the Global.asax to find out that I had no clue what was redirecting; I started doing a source control compare to see what changed where.
I found the below line had been added to the appSettings tag in my web config. After removing it everything started working correctly.
<add key="webpages:Enabled" value="true" />
After a bit of searching I found this article...
what is the function of webpages:Enabled in MVC 3 web.config
...which explains a little, but not why this setting would cause the site to redirect away from my default document to a URL that doesn't exist in either project or why my MVC project is being called at all.
Can anyone point me in the right direction?