I want to redirect some html page to aspx.
I try this in my web.config like below:
<urlMappings enabled="true">
<add url="~/report.html" mappedUrl="~/page.aspx?id=2"/>
<add url="~/product.html" mappedUrl="~/products.aspx?type=all"/>
</urlMappings>
but it doesn't work, is I thinking got something wrong?
Is there any better idea except to create html files and set the meta refresh?
Thx.
By default IIS won't run .html pages through the aspnet engine. You'll have to configure the server to pass all requests through the aspnet engine as mentioned in this article: http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET in the Finally section.
Related
I am recreating a site from VB .NET to MVC 4 ASP.NET. In the old project there is a system that sends an email to a user and within that email there is a hyperlink that can direct the user to view the specific task. I want to make all of the old emails work with the new recreated site. Here is an example of the hyperlink in the old system:
http://pppweb/accounting/ap/default.asp?etaskid=32698
And here is an example of what a hyperlink looks on the new system.
http://pppweb/accounting/ap/ApIssues/Task/32698
So I was thinking i could create a default.asp page in my MVC project and try and have it parse the taskID out. I am not exactly sure the best way to go about doing this?
I would advise against adding a classic .asp (not .aspx?) page in your project, since I'm not even sure there is a way to do that. You can, assuming you are running IIS7, map the url:
http://pppweb/accounting/ap/default.asp
to be handled by MVC by adding the following line to your web.config file:
<configuration>
...
<system.webServer>
...
<handlers>
...
<add name="aspnet htm" path="account/api/default.asp" verb="*" type="System.Web.Mvc.MvcHttpHandler" preCondition="integratedMode" />
Then, add a route for that url and requests should resolve to the normal route parameters you specify. From that point, you should be able to access etaskid from the query string easily enough.
Edit:
Alternatively, if the url matters a lot to you, you can specify a redirect rule from the old format url to the new one by using UrlRewrite module (also an IIS 7 feature). You can read about it here: http://www.iis.net/downloads/microsoft/url-rewrite
Our old website was built using ASP and now we are using Wordpress (IIS) utilizing a sub-directory. All of the old ASP files are still in the root directory and I'd like to redirect all of these file extensions to our new Wordpress site because the old ASP files are causing 404 errors.
I'm having a real difficult time figuring out what to put in my web.config file so all the old ASP pages are redirected to our new home page.
Thanks
The best option is to use the URL Rewriting extension for IIS ( http://www.iis.net/downloads/microsoft/url-rewrite ) which can also perform regex-based redirections. Create a new rule that matches (.+)\.asp and redirects as appropriate.
I don't know if you just want to do a 'dumb' redirect from all .asp-URIs to your WordPress root, or if you want to intelligently redirect users from the old .asp pages to their new WordPress equivalents (this is a good idea as it means search engine results and previous links won't be broken, I'm sure you can imagine how frustrating it is to follow a link that doesn't go where the user expects).
Thanks everyone for your suggestions, but because I don't have access to the server, my only solution was to work with the web.config file. I simply added the following code and everything now works:
<directoryBrowse enabled="true" />
<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
<add wildcard="*.asp" destination="/" />
</httpRedirect>
Is it possible to re-direct a request for a page 'XYZ.aspx' to 'ABC.aspx', without writing any code? We are using ASP.Net 4.0 with IIS 7.5.
The idea is that we want to remove XYZ.aspx page from our website, and if users still use old bookmarks that point to XYZ.aspx, then we want them to be taken to ABC.aspx in an automated manner.
there seems to be a few ways, link should hopefully help you out.
http://www.trainsignal.com/blog/iis7-redirect-windows-server-2008
you can forward the user through web.config file or you can do it through IIS too. but I I were you I would use web.config. in shared hosting u cannot touch IIS.
I found the answer. One needs to use the following in web config, and that's it.
<location path="XYZ.aspx">
<system.webServer>
<httpRedirect enabled="true" destination="http://localhost/mysite/ABC.aspx" httpResponseStatus="Permanent" />
</system.webServer>
UPDATE : This will also work if any query string parameters are passed to the page XYZ.aspx.
I have an asp.net website,
and i have set 1 page "search.aspx" as start page,
and when i type url like this:" http://localhost/websitename/subfolder/Search.aspx"
it opens properly.
but i want it to open when i type : " http://localhost/websitename/" like this only,
and i have set the "search.aspx" as start page.
Can anyone please help,
i tried changing property pages also.
but it did not help.
Start Page in Visual Studio just refers to the page which will be opened when you Run your solution.
When running localhost, the "Default Page" for ASP.NET is always Default.aspx (unless you do a lot of workarounds).
In IIS you have control over this however, by setting "Default Documents".
You need to set the start page in IIS. Here is a tutorial
http://www.ehow.com/how_4532283_set-start-page-microsoft-iis.html
There are two points to consider here.
Firstly, you need to look in IIS and see what "Default Documents" you have set up for that web application. If "search.aspx" is not listed then that page won't be served as a default page for that folder. If you add "search.aspx" as a default document then your page will show if you navigate to websitename/subfolder/
Secondly, are you providing a way to traverse to the subfolder? IIS will be looking for the default document in the ..websitename/ folder. If the default document was "default.aspx" you need to add some sort of redirect to the subfolder.
Alternatively, set the subfolder as the root folder of your website (unless you need to go up one level).
You have to specify a default document for the page in IIS, or make the default page redirect to the search page, alternatively use routing.
Here is how you set default document in IIS6.
Since you want a page in a subfolder to be the default your easiest path is either a redirect or routing.
you can try doing this.
take a blank index.htm page and add meta tag for redirecting to your starting page:
<head>
<title></title>
<meta HTTP-EQUIV="REFRESH" content="0; url=http://localhost/websitename/subfolder/Search.aspx">
</head>
Make default page(index.htm) in IIS for the website.
IIS7
IIS 6.0
use following setting in web.config:
<system.webServer>
<defaultDocument enabled="true">
<files>
<add value="index.htm" />
</files>
</defaultDocument>
</system.webServer>
reference:Default Document
I have a page with URL mysite.com/mypage.aspx and I want visitors to be redirected to this page if they go to mysite.com/mypage. It is only for this page and I wonder if this is possible to achieve in web.config. I do not have access to any source code, only to web.config (via FTP). I tried to log in to our web hosts control panel to check if there's any settings there I can use but it seems to be down for the moment.
So can I do something like this in web.config (it's ASP.NET 2.0 if that matters)?
Thanks in advance.
Edit: I tried
<urlMappings enabled="true">
<add url="~/index.htm" mappedUrl="~/default.aspx"/>
<add url="~/mypage" mappedUrl="~/mypage.aspx"/>
</urlMappings>
It works for index.htm but not (obviously) when there's no extension in the first place.
To the best of my knowledge, you can't do any url routing in code with asp.net 2.0 (only 3.5, 4.0 and you need source code for those).
Do you have access to IIS to UrlRewrite