Permanent Redirect Legacy Routes For Static Files In MVC?

Jan 12, 2011

Our old ASP.net site stored static images in a sub directory on the root called /images.

Our new ASP.net MVC site stores these images in the new layout of /Content/Images

I've changed all the pages in the site to cope with the new folder structure, but I'd like to set up Permanent Redirects from the old static images to the new location.

View 1 Replies


Similar Messages:

Web Development - Redirecting Old Asp Files To New Aspx Files (Permanent Redirect, SEO)

Jun 28, 2010

I upgraded my site from asp to asp.net.This means that all of my previous asp files became obsolete.I don't want to lose my Google Ranking of the old pages.

What is the proper way to redirect?I tried to catch all of the old asp pages is my 404 and then to:

if Request.QueryString("aspxerrorpath").contains("index.asp") = true then
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", "http://www.domain.com/index.aspx")
Response.Redirect("/index.aspx")
end if


but it doesn't catch asp pages, only aspx.

View 3 Replies

Http - Make 301 Permanent Redirect?

Jan 21, 2011

how to make 301 permanent redirect in asp.net?

I have written code in Global.asax file but my web client says it is not working,

i have written follwing code in Global.asax file:

protected void Application_BeginRequest(object sender, EventArgs e)
{
if (HttpContext.Current.Request.Url.ToString().ToLower().Contains(
"http://lsatfreedom.com"))
{
HttpContext.Current.Response.Status =
"301 Moved Permanently";
HttpContext.Current.Response.AddHeader("Location",
Request.Url.ToString().ToLower().Replace(
"http://lsatfreedom.com",
"http://www.lsatfreedom.com"));
}
}

View 4 Replies

C# - Detecting If Referrer Was From A 301 Permanent Redirect?

Jul 8, 2010

I am doing a 301 permanent redirect from an old server to a new server. When the new server's page is hit I want to be able to determine whether the user comes from the old site and then react differently, i.e. instruct user to re-book mark the new page.

View 2 Replies

Make Permanent 301 Redirect Work When There Are Parameters In The Query String?

Jul 22, 2010

I moved some of my old asp pages to new aspx website. In all of the old pages i used (for file example.asp):

Response.Status = "301 Moved Permanently";
Response.AddHeader("Location","http://www.domain.com/example.aspx");

The problem is that when the page domain.com/example.asp?param=value&param2=value2 is requested - the redirect ain't working...

View 1 Replies

How To Improve The Legacy Code Implementation, Response.Redirect

Nov 19, 2010

here is a legacy code which has following implementation Example1 and Example2.f we try to implement MSDN recommendation then the legacy code fails.

void Page_Load() {
if(condition) {
/// some condition
} else {
RedirectPage(url);
[code]...

View 1 Replies

C# - Ignore Routes For Files With Specific Extension?

Jul 12, 2010

I want to remove any mapped routes for files with a certain file extension.

RouteTable.Routes.Ignore("{root}.hello");

Works for any file that has the extension .hello in the root directory, however as soon as i go into any subfolders the 'ignore' rule isn't applied.

Ive tried lots of different combination's, but can't seem to get one that doesn't throw a compiler exception, or not work?

View 2 Replies

Permanent Redirect From Old .net Pages/site To PHP Pages/site

Jan 29, 2011

I picked up a new-to-me client who had a site built in ASP.net (which I do not host).I converted the site to PHP, which worked fine.I want to set up redirects for all the pages he had in the old site (it was a small site, so there was only 8 pages).As an example, the ASP.net url for the Contact page was www.domain.com/Contact - it is now www.domain.com/Contact.php (and so on).

For 301 redirects from one PHP page to another I normally use the .htaccess file:

Options +FollowSymlinks
RewriteEngine on
#custom redirects
rewriterule OldPage.php http://www.domain.com/NewPage.php [R=301,L]
#end custom redirects

What can I do to redirect these ASP.net pages to the new PHP pages?They are all static pages with no dynamic content.

View 1 Replies

MVC :: Routes.IgnoreRoute Not Ignoring Routes?

May 25, 2010

I'm trying to prevent direct file requests from being accepted, and have tried this:

[Code]....

None of these worked. I want the rule to exclude any file of any filename in any directory with a matching extension. How can this be done?

View 11 Replies

Necessary To Manually Cache Static Files In C#?

Nov 29, 2010

I have a class that is creating an instance of StreamReader to an xml file on the local filesystem.
It may be possible that this same file is requested multiple times per-second.

I was wondering whether I need to manually add this file to the System.Web.Cache and read it from there, or whether Windows itself is clever enough to cache the item itself so that it 'knows' when ASP.NET requests this file the second/third etc time that it doesnt have to do a disk seek/read operation and pulls it from its own cache?

This article: http://dotnetperls.com/file-read-benchmarks seems to back this up, but this: article:

[URL](although not discussing from a performance perspective, and maybe for other reasons entirely) lists how to add a physical file to the cache.

View 1 Replies

C# - How To Implement Caching Of Static Files

Mar 15, 2011

I use a Masterpage (asp.net webforms) on my site and I woluld like to implement caching of some static files, like javascript, css etc.

I've tried adding the following to my page_load (in the masterpage) but when I use Fiddler the static files are still under "no-cache".

protected void Page_Load(object sender, EventArgs e)
{
// Set cache for 1 hour on all computers and servers.
// ... Proxies, browsers, and your server will cache it.
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetMaxAge(new TimeSpan(1, 0, 0));
}

What am i doing wrong here?

View 1 Replies

Static Compression In IIS Does Not Work For Htm And Js Files

Apr 1, 2011

I'm trying to configure IIS 7.5 to compress static htm and js files. Here is my web.config for the web site:

[code]....

Compression starts working when I set doDynamicCompression to true. But I can't use this option because it is disabled at my hosting.

View 2 Replies

Configuration :: URL Rewriting Static Files Like CSS?

Nov 2, 2010

How do I rewrite the url for static files? When adding something like

RouteTable.Routes.MapPageRoute("test", "style/style.css", "~/Static/Styles/Public.css");

I just want the url /style/style.css to point to another static file on the webserver..

I'm getting this error:

There is no build provider registered for the extension '.css'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

View 5 Replies

How To Protect Static Files With Form Authentication On IIS 7.5

May 25, 2010

I have a website running on a IIS 7.5 server with ASP.NET 4.0 on a shared host, but in full trust.

The site is a basic "file browser" that allows the visitors to login and have a list of files available to them displayed, and, obviously, download the files. The static files (mostly pdf files) are located in a sub folder on the site called data, e.g. http://example.com/data/...

The site uses ASP.NET form authentication.

My question is: How do I get the ASP.NET engine to handle the requests for the static files in the data folder, so that request for files are authenticated by ASP.NET, and users are not able to deep link to a file and grab files they are not allowed to have?

View 1 Replies

MVC :: Publish Website Not Copying Static Files?

Mar 1, 2011

I am new to MVC. I am using MVC and VS2010. I am trying to publish my website to a remote server. All files are copied except some static pages i have kept inside a folder. for e.g. i have a folder named Content. I have around 5 .pdf files inside this folder and also a .css. When i do Build->Publish <appname> all the files including the .css is copied but not the .pdfs.

View 2 Replies

Wildcard HttpHandler Not Handling Static Files?

Jan 26, 2010

I had a look through some of the older questions, but I can't find anything.I have a Wildcard HttpHandler on my web app which is processing the url and working out if it can do anything with itIf it can't, then the StaticFile Handler should pick it up and just serve it as a static file (like an html file).The problem is, it's going through the Wildcard handler, then seemingly not going to the StaticFileHander. Is there something I need to do to the Wildcard handler, or in the web config?This is my web.config:

<add name="Wildcard" path="*" verb="*" type="Rewriter.RewriterHttpModule"
modules="IsapiModule" requireAccess="None" allowPathInfo="false"
preCondition="" responseBufferLimit="4194304" />
<add name="StaticFile" path="*.*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
scriptProcessor="%windir%Microsoft.NETFrameworkv2.0.50727aspnet_isapi.dll"
resourceType="File" requireAccess="Read" allowPathInfo="false" preCondition=""
responseBufferLimit="4194304" />

View 3 Replies

MVC :: BeginRequest Event Fires For All Static Files?

Oct 29, 2010

I was under the impression that static files (CSS, images, @font-face files, etc) bypassed ASP.NET completely, and were served directly by IIS. However, my BeginRequest event handler is being called for every HTTP request, including those for static files. This concerns me because I'm creating an Entity Framework data context to be used for the lifetime of each request in that event handler. I don't want to create those contexts if they're never going to be used.

I'm using IIS 7 on Windows 7 Ultimate with so special handler mappings defined. Do I have it wrong? Should these events be firing?

View 2 Replies

Rewrite Rule To Map Locations To Static Files

Jul 22, 2010

What I want to do it rewrite urls for a bunch of static pages in a locations folder such that

/london

maps to the physical file if it exist in the locations folder eg.

/locations/london.aspx

Is this possible with url rewrite. I can't get the rule to work.

<rule name="Rewrite Locations">
<match url="^([_0-9a-z-]+)/*" />
<conditions>
<add input="/locations/{REQUEST_FILENAME}.aspx" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="/locations/{R:1}.aspx" />
</rule>

View 1 Replies

Disable Website To Respond Request Except Static Files?

Nov 2, 2010

I have 2 website on my IIS which have the same physical location on disk. Example:

www.xxx.com path on disk : c:wwwxxx.com
img.xxx.com path on disk : c:wwwxxx.com

I want that img.xxx.com only response for static files like images, css and js files.

My main goal is to serve static files from a cookieless domain (using img.xxx.com for cookieless requests). But if I write img.xxx.com to browser i see the same content with www.xxx.com. I want to block all request to img.xxx.com except images, css and js request.

I don't want to set another folder for img.xxx.com because it is very hard for me to change all images url to new url.

View 3 Replies

Setup IIS 6 To Only Server Static Files From Virtual Directories?

Jun 21, 2010

We're having the same setup and receiving the same problem as:

[URL]

Setup
Server 2003 32bit, IIS 6
ASP.NET wild card mapping

A virtual directory mapped to an UNC share serving static images for a CMS in a load balancing environment

My question if it's possible to turn off asp.net from virtual and only serve static files e.g. images in the virtual directory, to avoid the problem with too many open connections?

If it's not possible I'll guess I have to implement a solution like [URL] to server the files from a local disc.

I found a possible solution at [URL] that removes the wild card mapping and makes it possible to turn of execution of asp.net files.

View 1 Replies

AJAX JavaScript Files Served From A Static Location?

Jan 5, 2010

I realise that this is going to be a fairly niche requirement and will almost certainly raise a few "WTF's" but here goes...

Within an ASP.NET Webforms application I need to serve static content from a local client machine in order to reduce up-front bandwidth requirements as much as possible (Security policy has disabled all Browser caching). The idea is to serve CSS, images and JavaScript files from a location on the local file system referenced by filesystem links from within the Web application (Yes, I know, WTF's galore but that's how it is). The application itself will effectively be an Intranet app that's hosted externally from a client but restricted by IP range along with standard username/password security. So it's pretty much a hybrid Internet/Intranet application but we can easily roll out packages of files to client machines. I am not suggesting that we expect nor require public clients to download packages of files. We have control to an extent over the client machines in terms of the local filesystem and so on but we cannot change the caching policy.

We're using UpdatePanel controls to perform partial page updates which obviously means that we need to Microsoft AJAX JavaScript files. Presently these are being served (as standard) by a standard resource handler within IIS/ASP.NET. Ideally I would like to be able to take these JS files and reference them statically from a client machine, and no longer serve them via an AXD.

My questions are:Is this possible?If it is possible, how do we go about doing so?

In order to attempt to pre-empt some WTF's the requirement stems from attempting to service a requirement with as little time and effort as possible whilst a more suitable solution is developed. I'm aware that we can lighten the load, we can switch to jQuery AJAX updates, we can rewrite the front-end in MVC etc. but my question is related to what we can quickly deploy with our existing application architecture.

View 2 Replies

Configuration :: Hiding And Protecting Static XML Files - Embedded Resource?

Nov 3, 2010

Does precompilation have any effect on XML files? i.e. can I obscure/protect xml files using precompilation? I assume that it has no effect as they aren't code.

If I use XML files as Embedded Resources, they appear in the DLL in a text editor as normal text. If the dll is edited and saved using a text editor, will it still work if it is unsigned?

View 2 Replies

How To Mix DynamicData Routes With Mvc Routes

Jan 9, 2011

I am trying to create an Area for running DynamicData with scaffolding as an administration part. It's probably working as it should but I can't get the routing to work.

In my global.asax I have the following function to register the routes:

[Code]....

Unfortunately the "best" thing that happened to me so far was that when I check the default tables I get a message about (MetaModel.VisibleTables)

[Code]....

The problem is that I don't know why this is. Is it the routing or something else? Is it perhaps some security thing or can I not put dynamic data inside an area?

The DynamicData folder itself is located in the root of the application since that is the convention it uses and I have no intention to override that.

View 1 Replies

C# - Keeping Basket More Permanent?

Feb 22, 2011

I need to keep my basket more permanent I have two options and I want to choose the best one.

I have eCommerce web site application in asp.net and there is a basket include products which are selected by users before, so options:

1- keep basket in database (consider the cost and time to store and retrieve information)
2- store my basket in Cookies (I don't know what the implementation is)

I couldn't use session because it is not permanent and clear by closing browser.

My goal is : when the user close the IE for 1 day or 2 days make ability to remember all products that already added to basket.

In addition, my basket is store in hash-table now, for example : {1:4055,2:4588,...} they are ID and product code(keys). they are all save in a hash table.

View 1 Replies

C# - IIS Redirect Moved Files?

Aug 18, 2010

I would like to reorganize the directory structure on a hosted website (i.e. I can not go in and configure the IIS settings).

Say I had 3 files in the root directory:

fruitcake.html,
chocolateCake.html, and
appleMuffins.html

Now, I want to move them to a new folder called Recipes. This is easy enough, but there are a lot of existing links out there that point to the other files. How would I construct a 404.aspx page to read in which file was in the address bar, then update the browser to go to the new location?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved