SignalR /signalr/hubs 404 Not Found - asp.net

I am trying to deploy a SignalR site on IIS. Code all works fine in VS. But getting the 404 not found error trying to resolve signalr/hubs so far I have tried.
1) Changing the Script ref to:
script src="<%= ResolveUrl("~/signalr/hubs") %>" type="text/javascript"></script>
2) Modifying Web.Config to include :
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
</modules>
</system.webServer>
3) Changing the invoke requests on IIS for UrlMappingsModule.
4) added SignalR.Hosting.AspNet.dll to see if that would help anything.
Not sure what else to try or check, any help or point in the right direction?

The order of route registration matters. I had this exact problem and fixed it by ensuring my global.asax.cs looked like this:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
RouteTable.Routes.MapHubs();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
}
This was in a web site using SignalR, MVC and WebApi all together.

The reason of this 404 error is hubs are not mapped, previously it would have to be done as answered by SimonF. If you are using SignalR version 2 RouteTable.Routes.MapHubs(); is now obsolete. For mapping hubs you can create a startup class as below.
[assembly: OwinStartup(typeof(WebApplication1.Startup))]
namespace WebApplication1
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
// Any connection or hub wire up and configuration should go here
app.MapSignalR();
}
}
}
referenace : http://www.asp.net/signalr/overview/releases/upgrading-signalr-1x-projects-to-20

Try adding a wildcard application map to your server to help map the unknown extension in the script URL "~/signalr/hubs"

I was able to fix the 404 on ~/signalr/hubs by changing the following appSetting in web.config to "true".
<add key="owin:AutomaticAppStartup" value="false" />

If you are working on webforms, Please take the following steps
In the webconfig:
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true"/>
In the page add reference to hub as
<script src="/signalr/signalr/hubs"></script>
instead of
<script src="/signalr/hubs"></script>

Make sure your site's AppPool targets the correct version of .NET Framework.

I might be a little late but hope it helps someone.
Make sure this code run on start.
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
RouteTable.Routes.MapHubs()
End Sub
Because I added a global.asax to my application and then a codebehind but put this in Global.asax file
<%# Application Language="VB" CodeBehind = "Global.asax.vb" %> /*This was wrong*/
So when i tried to run the application, the Application_Start in my global.asax did not initialize the hub. that's why it couldn't resolve signalr/hubs
fixed with this in my Global.asax
<%# Application Inherits="_Global" Language="VB" %>
and this in my Global.asax.vb:
Public Class _Global
Inherits System.Web.HttpApplication

Check web.config, on segment AppSettings add
<add key="owin:AutomaticAppStartup " value="false" />
on Key must be white space on the end of the name key, like #Randy H.

I had no issues with routing in MVC3, but did get the path wrong. I would suggest you look at the source and see where the script is actually pointing, make sure it is resolving the application directory ok. And make sure you can physcially open the file with the correct path with your browser. E.g.
<script src="/MyWebApp/signalr/hubs" type="text/javascript"></script>
Can you open the file from a browser (replacing it with the correct subdirectory)?
If not, the hub might not be set up correct and it might point you in the right direction. Fiddler it.
The syntax I used was:
<script src="#Url.Content("~/signalr/hubs")" type="text/javascript"></script>
It might be the difference between Url.Content and ResolveUrl

Similar problem I had on IIS version, I fixed it by restarting AppPool, restart web and its working now.

there are potentially many causes of this 404 - a few common ones can be found by
Hit the url in the browser /signalr/hubs - if there is an error, you will see the full error come back.
check for duplication of HubName attribute if you have base class
ensure you have the correct version referenced in all projects (as to avoid binding errors)

For me the solution was to reinstall all the packages and restore all the dependecies.
Open nuget powershell and use this command.
Update-Package -Reinstall

I had the same problem, it was an asp.net project using signalR, it worked properly before I published but when I hosted it in IIS, it didn't.
After I inspected I realized the address /signalr/hubs is not correct, let me explain more, just do the following steps:
Open up your web application in the browser (Using IIS), you see the interface you designed, yeah? now press ctrl+U or right click on the page an select View Page Source.
You will see multiple links starting with <script> tag at the top of the page, find something like <script src="/signalr/hubs"></script> now click on it, if you are taken to the page which involves "404 - File or directory not found."you have some mistakes on defining address, find the true address and change the address in the address bar to observe the true result
In my case I needed to add my project name at the start of the address, so I had to change the address from:
<script src="/signalr/hubs"></script>
to
<script src="/MoveShape/signalr/hubs"></script>
in which MoveShape was my project name, now after pressing ctrl+U in the browser and following previously told steps, you click on the link and this time you see the true result, the page show codes starting with:
/*!
* ASP.NET SignalR JavaScript Library v2.2.2
* http://signalr.net/
*
* Copyright (c) .NET Foundation. All rights reserved.
* Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
*
*/
yeah! that's it, it works properly, keep in mind that it had no problem when I was testing it using Visual studio but not after hosting in IIS, as others have recommended make a correct address by applying <%= ResolveUrl("~/") %> or other methods.

In my case, I lose some owin dependencies then I got the 404 NotFound error.
When I added following dependencies, I retrieve the proxy javascript file clearly from expecting URL. Like URL:1111/singlar/hubs
Microsoft.Owin
Microsoft.Owin.Core
Microsoft.Owin.Host.SystemWeb
Microsoft.Owin.Security
Owin
Hope the answer helps someone.

In my startup.cs I changed the order from
app.UseWebApi(configuration);
app.MapSignalR();
to
app.MapSignalR();
app.UseWebApi(configuration);
And that fixed the issue.
It was working fine on localhost but the problem was that I have a custom global message handler that I'm using to display custom 404 messages on prod.
WebApiConfig.cs
config.MessageHandlers.Add( new WebApiCustomMessageHandler() );
public class WebApiCustomMessageHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken )
{
HttpResponseMessage response = await base.SendAsync( request, cancellationToken );
//...
//... custom 404 handling
//...
return response;
}
}
I was getting 404 for all requests to .../signalr
Fixing the order in startup.cs fixed the 404 issue in the global message handler.

What worked for me was that in the App_Start I created a new item and selected the OWIN Startup class.
Then I modified it to look like this: Adding the app.MapSignalR();
public class Startup1
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR();
}
}
With This in the HTML
<script src="~/signalr/hubs"></script>

Related

No owin.Environment item was found in the context

Microsoft recently introduced new ASP.NET Identity - replacement for old (Simple)Membership. Unfortunately, I can't use this new membership system in my old project because it throws System.InvalidOperationException: No owin.Environment item was found in the context. This is a known bug, but Microsoft keeps silence about this issue. The easiest way to reproduce this bug - it's to create a new web application (MVC, WebForms or WebApi - doesn't matter) in VS 2013 (with Web Tools 2013 Preview Refresh) and then go to the login page. It will work. Then change namespace in your application to anything else than original namespace and login page will throw that error. Changing namespace back to original (the one you used at the creation of a project) will solve this problem.
It looks like .net stores somewhere something related to the original namespace, but I can't find what and where, it's not in the project folder. I know that stackoverflow is not a place for a bug reports, I just hoping that someone already found a solution for this issue or maybe people involved in the development of ASP.NET Identity will see this.
Most likely it cannot find the OWIN Startup class. The default convention for the Startup class is [AssemblyName].Startup. If you're no longer following that convention you'll need to specify the full name of your Startup class in the Web.Config.
The next release of Microsoft.Owin.Host.SystemWeb package now throws detailed exception messages when the Startup class cannot be found.
I had the same issue, it was fixed after making sure this line was in web.config:
<add key="owin:AutomaticAppStartup" value="true" />
I had the exact same error, but as it turned out I had another configuration problem in my web.config. My web.config was missing the attribute defaultLanguage="c#" in the compilation element under system.web.
In this case it will default to VB. So unless you have your Startup class written in VB you should change the default language to C#.
Not correct:
<compilation debug="true" optimizeCompilations="true" targetFramework="4.6.1">
This is correct (unless you use VB):
<compilation debug="true" defaultLanguage="c#" optimizeCompilations="true" targetFramework="4.6.1">
Cleaning ASP.NET temporary files helped me with this exact problem
I created two new projects called TesteMvc5.2 and TesteMvc5.0 and both of them didn't work at start
this is because the default namespace is different from the assembly name.
but after I put the line
<add key="owin:AppStartup" value="TesteMvc5._2.Startup, TesteMvc5.2" />
on the web.config it worked fine.
I tried everything mentioned on this page but nothing worked. Then I found out about a setting in IIS named owin:AutomaticAppStartup. You can find it in the Application Settings page of the IIS Manager for the Default Web Site. Check to see if that setting is true. If not set to true. This worked for me.
This is the website where I found the answer:
http://gotoanswer.stanford.edu/?q=Microsoft.Owin.Host.SystemWeb+and+still+getting+No+owin.Environment+item+was+found+in+the+context
If you happened to have copied the below config from MVC4, you should remove it from web.config
<add key="owin:AutomaticAppStartup" value="false" />
I had this same issue. I fixed it with the web.config.
However I had changed the assembly name and namespace and did not find the original assembly name anywhere anymore.
I then discovered that clean was not removing the original assembly from the bin.
Aftter deleting the bin litter, I was able to remove the web.config OWIN entry.
None of the above answers worked for me.
Turned out my project was missing the "Startup" class that contains the following:
using Microsoft.Owin;
using Owin;
[assembly: OwinStartupAttribute(typeof(NAMESPACE.Startup))]
namespace NAMESPACE
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
}
This file called "Startup.cs" is located on the root folder (~/) of your project.
My "Web.config" doesn't have any of this "Owin" configuration posted on the other replies.
Had same problem. Thanks for the shared solutions.
this..
<add key="owin.AppStartup" value="Namespace.Startup, Namespace"/>
<add key="owin:AutomaticAppStartup" value="false"/>
fixed for me
I have no idea why this works but it did!
My problem was in VS2013. In the WebConfig, debug was set to true and I got that error. When I set it to false it worked fine and then I reset to true and it continued to work OK!
At first when debug was true before changing to false, I put a break point in my StartUp code and it wasn't reached at all. After changing to false pressing save and then back to true the StartUp code was called and the program works like it should.
I experienced this error in an Optimizely (Episerver) solution where I had two feature branches using the same CMS database. In one feature branch I was working on a proof of concept using a visitor criterion. So I had created something like this:
public class SomeVisitorCriterionSettings : CriterionModelBase
{
public override ICriterionModel Copy()
{
return base.ShallowCopy();
}
}
[VisitorGroupCriterion(
Category = "Some category",
DisplayName = "My visitor criterion")]
public class SomeVisitorCriterion : CriterionBase<SomeVisitorCriterionSettings>
{
public override bool IsMatch(IPrincipal principal, HttpContextBase httpContext)
{
// match logic here..
}
}
And within Episerver -> CMS -> Visitor Groups I had created an instance of this visitor criterion. After switching to the other branch where this code did not exist, but the instance in the database did, the Owin exception was thrown.
Deleting the visitor criterion in the CMS resolved the issue, but I honestly have no idea why this sort of exception is thrown. I would love to know though..
I have tried all of the above suggestions, without success;
then reading the documentation at:
https://learn.microsoft.com/en-us/aspnet/aspnet/overview/owin-and-katana/owin-startup-class-detection
I understood that the error was in the call to the assembly in the Startup.cs file:
wrong code:
[assembly: OwinStartupAttribute(typeof([AssemblyName].Startup))]
right code:
[assembly: OwinStartup(typeof([AssemblyName].Startup))]
so, I fixed the error removing the word Attribute from OwinStartupAttribute
adding default language to compilation in web.config did it for me!

Troubleshooting custom VirtualPathProvider

I have just created a customized VirtualPathProvider for my ASP.NET web application. It basically maps all virtual files in "~/Storage" and subdirectories to a directory other than the solution's directory.
Code essentials
private bool IsPathVirtual(string virtualPath)
{
String checkPath = VirtualPathUtility.ToAppRelative(virtualPath);
return checkPath.StartsWith(VirtualRootPath, StringComparison.InvariantCultureIgnoreCase);
}
public override bool DirectoryExists(string virtualDir)
{
return IsPathVirtual(virtualDir) ? ((FileSystemVirtualDirectory)GetDirectory(virtualDir)).Exists() : Previous.DirectoryExists(virtualDir);
}
public override bool FileExists(string virtualPath)
{
return IsPathVirtual(virtualPath) ? ((FileSystemVirtualFile)GetFile(virtualPath)).Exists() : Previous.FileExists(virtualPath);
}
In my case VirtualRootPath = "~/Storage", but that it configurable.
The problem
In IIS Express, when I debug via Visual Studio, the two public methods, required to resolve a virtual path, are not always called.
Calling http://localhost:7749/Storage triggers breakpoints on both methods. A 404 error is returned and desired. This is a correct behaviour to me
Calling http://localhost:7749/Storage/ExistingFile.txt doesn't trigger debug, and a different 404 error is returned. This is not correct
The difference between the two 404 errors is that when I call for the directory, it's ASP.NET responding (Server error in application '/') but when I call for the file inside that directory, it's IIS 8.0 responding (HTTP Error 404.0 - Not Found).
The question
Why, even if I correctly registered the VirtualPathProvider in my HostingEnvironment, doesn't IIS 8.0 let ASP.NET pipeline handle the HTTP request so it could be resolved correctly?
The workaround
After reading VirtualPathProvider doesn't (quite) work in production on IIS 7.5 I realized it could be a Web.config problem. Judging from the other question, it looks like that IIS handles certain file extensions independently, no matter if ASP.NET maps those to a virtual resource, a controller, or anything else. So, since I was trying to read an XML file (and perhaps not a JPEG), IIS didn't bother ASP.NET.
The workaround has been putting this line in Web.config's system.webServer.handlers section:
<add name="AspNetStaticFileHandler-XML" path="*.xml" verb="*" type="System.Web.StaticFileHandler" />
But this workaround works only for XML files. How to make a permanent fix that works for all files under the storage directory?
You can specify the storage directory as part of the 'path' field in the config, as follows:
<add name="AspNetStaticFileHandler-Storage" path="Storage/*" verb="*" type="System.Web.StaticFileHandler" />

asp.net mvc errorhandler not showing custom error page

I am trying to follow the examples in this link and this one but instead of showing the error page I get an HTTP 500 Internal server error.
I have the <customErrors mode="On" /> set in the webconfig. I have even tried applying the [HandleError] filter to the controller class. I tried without as well. The Error.aspx is present in /Views/Shared/ as well so it couldn't be a case of no file found.
I threw a DivideByZero exception in my controller's action method. I want to follow that example so that I can specify a separate error page for all the actions that need them.
I am using the aspx view engine in a blank project that I created. That should not be the reason for it right?. I am also using a master page for this. Anything that I could be missing?
Thanks
Edit-Added Code
I added this code to a new project and made the web.config entry <customErrors mode="On" />
[HandleError]
public class HomeController : Controller
{
//
// GET: /Home/
[HandleError]
public ActionResult Index()
{
throw new DivideByZeroException();
return View();
}
}
It didnt work! Then I commented that DivideByZeroException and in the aspx view just added and invalid Model.Property. In both instances I got the Internal server error. I have done everything there is to be done as per documentation. I see a lot of other people having the same problem and not being able to solve it too. Is this a bug in MVC 3?
I think I have figured out what really was the problem. My main Home page index was in a master page. I added the same master page to the default error page that comes out of the box with Visual Studio and it worked for me.
The documentation needs to point out more clearly this important requirement,... if it indeed is one.
Another amazing revelation is that you don't need to decorate your controller classes with the [HandleError] attribute. It works without that as well for the default Error view. You may provide that attribute if you want a specific custom view for your action or controller.
Like so:
[HandleError(View = "CustomError")]
...where CustomError.aspx is just another plain aspx view page in either the shared folder for the View or in the View-Controller folder itself.
Has anyone got this working without putting the error pages in a master page, where the main calling page that throws the error is in a master page?
The HandleError filter doesn't catch all the errors. It doesn't catch exceptions that are raised outside controller actions/action filters. Also, it doesn't catch HTTP exceptions having status code other than 500.
So you have to make sure where the exception is getting thrown and you should not rely only on the HandleError to return the custom error page but you also have to set a custom error page in the customErrors section as well.
<customErrors defaultRedirect="error.htm" mode="On"
redirectMode="ResponseRewrite" />
Make sure you have activated custom errors in your web.config:
<customErrors mode="On" />
Also make sure that the ~/Views/Shared/Error.aspx template is present because this is what will be rendered in case of error.

Handling Expires Headers in ASP.Net MVC

I need advice or suggestions on how to add Expires Headers to my CSS, Image and JavaScript files in ASP.Net MVC.
A key issue is that the software is not in a single location. It is distributed to clients who handle the hosting so I would rather have a solution that doesn't require manual configration in IIS unless it's unavoidable!
I googled around and the majority of answers seem to be focused on content that is returned via a controller. Can't do that for JavaScript files though..
Which IIS Version are you using?
If by 'manual IIS configuration' you mean having to open the IIS manager console, IIS 7.5 (and I think 7 as well) allows you to add expires headers to static content using only the web.config:
<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="00:30:00" />
</staticContent>
</system.webServer>
You can do something like this by writing a custom handler for your javascript files. In your Web.Config file of your MVC project look for the httpHandlers section. Add something like the following line:
<add verb="GET" path="/YourScriptsFolder/*.js" type="Your.Project.Namespace.And.Custom.Handler, Your.Assembly.Name" validate="false" />
This will force all requests for js files in that folder through your custom handler which will look something like this:
class CustomHandler : IHttpHandler
{
#region IHttpHandler Members
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
// Set any headers you like here.
context.Response.Expires = 0;
context.Response.Cache.SetExpires(DateTime.Parse("3:00:00PM"));
context.Response.CacheControl="no-cache";
// Determine the script file being requested.
string path = context.Request.ServerVariables["PATH_INFO"];
// Prevent the user from requesting other types of files through this handler.
if(System.Text.RegularExpressions.RegEx.Match(path, #"/YourScriptsFolder/[^/\\\.]*\.js"))
context.Response.Write(System.IO.File.ReadAllText(path));
}
#endregion
}
I haven't tested this code so you might run into some issues but this is the basic idea. There are a plethora of examples on ASP.Net custom handlers throughout the web. Here's a good example:
http://www.developer.com/net/asp/article.php/3565541/Use-Custom-HTTP-Handlers-in-Your-ASPNET-Applications.htm
Another, less complicated option is to add a randomized or versioned query string to the end of the file path.
<link rel="stylesheet" type="text/css" href="somecssfile.css?version=1.0.0.3" />
When you change the version, the browser will get a new copy of the file.

Why won't my MVC project work after publishing it?

I recently published my first MVC 2 project to a commercial web server, running Windows 2008, and which purportedly supports other MVC sites without issue, but have been experiencing some problems. Here is the high-level structure of the project. As you can see, it is very simple:
But, after the site is published, and I navigate to the URL, I get "HTTP Error 403.14 - Forbidden: The Web server is configured to not list the contents of this directory."
So, I contacted the web host about it and was told I had to include a default landing page, such as Default.aspx, Index.aspx, etc. I doubted this response was accurate because I thought MVC Routing would have taken care of this, but I did as suggested anyway, adding a redirect to my home controller in the Default.aspx.cs codebehind, but got an HTTP Error 404. I added that redirect per advice similar to that found in this article: http://www.58bits.com/blog/CommentView,guid,10b2ddfa-057c-41d0-bdc7-564b212ce896.aspx.
I've been going back and forth with the web host about this for over a week, across about a dozen different responses and answers, yet I have not been able to find a resolution to this. I am sure this is a simple thing to resolve, but I have no idea what to try next, or what to suggest to the web hosting support that they try next.
Soooo ... knowing that the StackOverflow community is smarter than me and the support techs for my web hosting company combined, a thousand times over, I'm hoping you can help me work toward a resolution here, so I can successfully publish my project and access it without error.
There's a few things that could be causing the error:
Issue with the MVC libraries
The production server might not have the MVC libraries stored in the GAC. To fix this, all you have to do is go into your MVC project's References pane/folder and find System.Web.Mvc, System.Web.Routing, and System.Web.Abstractions. Now, select them by Ctrl clicking on them, and set Copy Local to true in the Properties window.
It's hard to know before you publish to a server whether or not this is the case, so I recommend just setting the assemblies to copy local all the time.
Landing Page
Your landing page may have issues. From my experience with ASP.NET MVC, I've seen that a landing page is required for IIS to function correctly. I'm using the page that was included in the ASP.NET MVC 2 template. You should compare mine to yours to see if you have everything that's needed:
Default.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="YourNamespace._Default" %>
<%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%>
Default.aspx.cs:
using System.Web;
using System.Web.Mvc;
using System.Web.UI;
namespace YourNamespace
{
public partial class _Default : Page
{
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
HttpContext.Current.RewritePath(originalPath, false);
}
}
}
Permissions
Based on the first HTTP status code you got, there may be a permissions problem. The folder containing your MVC application must be defined as an application and set to the appropriate permissions.
It's quite easy to do both those things through IIS. However, you probably don't have access to IIS; if you do, you're very lucky!
Otherwise, you can change the permissions through FTP using the chmod command. You can connect through Filezilla, a very good open-source FTP client, a just do it through a right-click + dialog box.
As for defining the folder as an application, you should check whether you can do it through any of the IIS things provided to you by the host. If not, contact them and ask them to set it up.
Good luck! Hope I helped.
It may be that your production IIS doesn't have the MVC reference files loaded for your site. I ran into the same issue when I loaded a MVC site to a host that said "we fully support MVC." You can try publishing using the "all project files" option. I believe the issue can also be resolved by going into your references folder and selecting the mvc references. I'm not at my developer machine right now but I believe you change a certain property for the references to have them included in your published files.
Try pre-compiling your application. In visual studio setup a Deployment project and then deploy it in release mode.
Because it's pre-compiled you aren't relying on IIS to compile the project for you to run it. This is what I always do these days as IIS on the production server can be a pain if I need to force it to re-compile or update..
Based on the comments and replies above, I ended up exploring wildcard application mapping by asking my web host if they support it. Here is what I got in response:
Wildcard mapping is not supported by our services.
If you would like to use URL re-writing, which is the same as rerouting please use the example bellow.
Example of using URL rewrite map where the following URL
/default.aspx?id=1 will be replaced with /default.aspx?id=25
<rewrite>
<rewriteMaps>
<rewriteMap name="/default.aspx?id=1">
<add key="1" value="25" />
</rewriteMap>
</rewriteMaps>
<rules>
<rule name="Rewrite rule1 for /default.aspx?id=1">
<match url=".*" />
<conditions>
<add input="{/default.aspx?id=1:{REQUEST_URI}}" pattern="(.+)" />
</conditions>
<action type="Rewrite" url="{C:1}" appendQueryString="false" />
</rule>
</rules>
</rewrite>
If what you are trying to do is not URL re-writing but is URL redirection please use the example bellow.
To redirect your web site using ASP create file "default.asp".
Place the following code inside:
<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.new-url.com/"
%>
To redirect your web site using HTML:
<HTML><HEAD>
<META HTTP-EQUIV=Pragma Content="No-Cache">
<META HTTP-EQUIV=Refresh Content="5;URL=http://YOURURLWHEREYOUWANTTOREDIRECT">
</HEAD>
Will any of the stuff above even work?. Seriously, should it be this hard publish an MVC project? I'm really starting to get frustrated ... :(
Should I just look for a new web host? Would that make a difference?
The following request is sent:
http://stackoverflow.com?variableValue=87
redirect page using variable values in a Query String
:-
Dim variableValue
variableValue = Request.QueryString("Occassion")
if variableValue = 87 then
Response.Status="301 Moved Permanently"
Response.AddHeader "Location","http://www.google.com"
end if

Resources