I've just installed and configured my server (WS2008, IIS7) with version 2 of the URL Rewriting Module. I've setup a simple static redirect as follows
/contact >>> /pages/contact/default.aspx
So users of the site have a simple url to get to the original, longer file path. It works great and even post backs to the right place.
My question is regarding the mapping of this page, now that the URL has changed, when I go back to my local development version. I develop using VS 2008 and it's built in web server, alongside another developer with the same setup, using SVN as source control. Now as far as I know there is no way to configure URL rewriting for these instances. So other than changing all of the path names used in the project before we publish and release it (not a realistic solution), I don't see how we can continue to work in this way. Is a different development configuration the answer or are there solutions to this?
Thanks
Maybe this is too obvious, but... what's stopping you from running IIS7 on your dev machines? I highly recommend IIS in the dev environment. Especially with IIS7 due to the new integrated pipeline. Doing anything else is like developing with "software X" when you're going to push "software Y" to your users.
If there's some reason you can't do that... Mike J's answer is quite reasonable: use a custom HttpModule.
This is kind of a hackish solution. Add a httpmodule to your project that adds a filter to the Response stream. This filter would replace all instances of "/contact" with "/pages/contact/default.asp". Then only add the httpmodule into your development web.config file.
Related
I'm not sure if this is the best/correct place for this type of question. But I have an existing .NET website which I am moving from our dedicated EC2 server to an Azure Web App.
However, this current site uses an .htaccess file with about 200 redirects (301 from old urls to new ones) which is powered by ISAPI rewrite (Which was installed manually on the Win2008 server).
I need to keep these redirects, but wondering how everyone else deals with permanent Url redirects on .NET applications when moving to an Azure Web App (From a dedicated server that had ISAPI rewrite installed)?
Putting them all in the web.config seems a little odd to me? And I don't know how that would affect performance?
Any advice or pointers would be appreciated as always.
I always put them in the web.config.
If you think it will be too messy, you can put them in a separate file and use the configSource attribute to link to the file.
I've developed a new WEB API 2 that works great locally, however when I upload the same code to my production server (Arvixe in this case) all I get is a 404 when I call it. I've spent HOURS searching the web, reading forums, etc.. and have been able to find no resolution, so I'm asking here as my last effort.
I'm currently only testing with the default project that gets created when you do New Project > ASP.NET Web API 2 Empty Project in Visual Studio. This creates an empty project with a single ValuesController. You should be able the JSON response by called /api/values, but this doesn't even work.
I'm using Fiddler to test the API locally and on the web server.
http://localhost:1993/api/values <--- works great
but
http://api.mydomain.com/api/values <--- returns 404
Note: I created a subdomain "api" in this case, but everything for the code for the API is unchanged from when it was created.
Why in the world does this work locally but not on the production web server?
That the server returns 404 (Not Found) may indicate a lot of things. However you can check using the following step:
Add a simple text document like readme.txt to your a folder sub-domain http://api.mydomain.com, and try to get access to that. If you can't access to that file, it means that the subdomain is not configured properly.
Publish the webservice using the "Publish" functionality, so that all DLLs will be copied.
After that,try to reach the Web ApI again.
Hope that help.
"Note: I created a subdomain 'api' in this case, but everything for the code for the API is unchanged from when it was created."
Above comment of your's is suspicious, you should publish your WEB API application in the root directory. Like if http://example.com is pointing to "MyExample" folder, then application should be published on "MyExample" folder.
After that you will be able access your api with http://example.com/api/{controller}/{action}
Just a simple suggestion which I'm sure you have already considered, but have you opened the http port 80 on the server's firewall?
Also stick a plain old html file in the root of your project and see if the server serves it up.
in your case, since you create a subdomain of 'api', you should try
http://api.mydomain.com/api/api/values
note that if you're using database for the function, you should change the connectionString in your web config
Please verify the .net framework on you hosted domain that may be old one.
Web api 2 is supposed on 4.5 framework.
One reason for web api 2 method working OK on local machine but not on production server is that the method you are calling is working on local machine but not on remote server. In such a case you will receive message 404 or 500, and you would be lost why this routing is failing.
Why a method would fail on remote server, well there may be many reasons. For me, I was querying database in my method and my connectionString was not set for remote server.
One way of resolving it would be to put some very simple code in that particular method and test that routing is working. Then check your original code for errors reasons.
I'm trying to figure how how/if it's possible to add a blog to a subfolder on an existing azure site.
BlogEngine seems like it would be a good choice since it's written in .net and from what I've read easy to setup as a standalone site on azure.
The problem I'm running into now is how can I setup my sub folder /blog as an application in azure. I know locally you can just pull up IIS and rightclick -> convert to application. But is there something I could put in the web.config or publish settings that would achieve the same thing?
Right now I'm getting an error message because /blog has it's own web.config file.
If there's an easier way or I'm thinking about this wrong let me know that too :-)
Thanks,
Andrew
EDIT
I contacted azure supported and they suggested I upgrade from a azure web site to a azure VM.
At this time there isn't a good way to run a full fledged blog engine side by side with an azure website without setting up a VM.
I ended up pulling from a google blogger blog using their data API. Not exactly what I was wanting to due but I couldn't take on the extra cost associated with a VM solution.
I request a page in Sitecore and I get a 404 from IIS. The site works on my development environment & staging. This is on the production machine, which is a new install. I've never actually seen it work. The fact that it's giving me an IIS 404 (instead of a Sitecore 404) seems to indicate that whatever handler Sitecore uses isn't being recognized or isn't set up properly. I'd appreciate any suggestions about where to begin looking or what the issue might be.
We're in II7 running in classic mode.
I have the same issues if I run Sitecore in classic mode. Why don't you try running in Integrated mode, for all handlers to work propperly? Your Sitecore login page works, so that indicates that you have unzipped the Sitecore folder corretly. I'd suggest you to try Integrated mode.
It sounds like a permissions issue, check that Network Service (or Application Pool Identity) has the correct access to all of the Sitecore folders.
This looks like a fairly good guide on this:
Sitecore folder & IIS permissions
You could also try exporting the IIS setup for production and staging and comparing the two to make sure nothing odd with the setup.
Have you tried running the installer? If you are cleaning up someone else's install, there's no telling what they did... far easier to start again. You can easily connect to an existing database, or install a package with all your content once you've got a good working Sitecore instance.
I'm currently looking into url-rewriting and how it should be done right and hope you have some inputs here.
At the current stage of development only the kind of url-rewriting I'm interested in is adding facebook like behavior to businesses to which we provide services on our site, i.e. www.mysite.com/ShowBusinessInfo.aspx?id=1 should be rewritten to www.mysite.com/HostedBusinessName. - The idea is that when a business registers on our site they can choose whatever the last part of the url should be.
What would be the best way to support this feature? Custom IHttpModule, Global.asax (I'm afraid that this is too slow?), UrlRewriter.net/UrlRewriting.net or a completely different solution.
The site is developed in asp.net and runs on IIS 7.5.
I've actually done something like this before and this is the article I used as a resource: http://stweet.wordpress.com/2010/03/15/creating-a-new-website-programmatically-on-iis-using-asp-net/
This article will tell you how to programmically add a web site to your IIS using C#. Keep in mind that depending on how your IIS and DNS is setup, you may need to also modify your DNS server. You can find various scripts for doing this here: http://msdn.microsoft.com/en-us/library/ms682129%28VS.85%29.aspx
Hope this helps!
If you have fairly simply rewriting rules, I'd use an IHttpModule that attempts to match the URL's LocalPath property with a value in your DB, and then calls context.RewritePath(string).
If you have more complex stuff, then I'd start looking at UrlRewriting.NET or the routing options in ASP.NET.