I've got a ASP.NET MVC 4 client for which I would like to load the IIS rewrite rules dynamically from a CMS. The set up is IIS7.5 with URL rewrite module 2 and .NET 4.5.
I've been reading the article, 'http://www.iis.net/learn/extensions/url-rewrite-module/using-custom-rewrite-providers-with-url-rewrite-module' but I would like to implement this using WCF instead of SQL Server. Does anyone know how to implement this?
The idea is that I can then control all rewrite rules from a CMS system instead of having to modify the web.config manually.
Or is it possible to use a dynamic config source in the web.config which points to and reads from a WCF service?
Related
I'm looking at working my long-standing API to run on IIS rather than in a desktop app as it is now. Everything on the API is working so I'd rather not change too much if I don't have to. I know about the new Web API template in ASP.NET MVC 4 and I've worked with it, but I found that it didn't give me the control over everything that this particular project needs.
So my question is, is there any way to build an application for IIS that has something like an entry-point where I can just get a web request then use entirely my own code from there? Or do I have to build something that uses the Web API?
Yes, you'll want an ASP.NET handler.
How To Create an ASP.NET HTTP Handler by Using Visual C# .NET
http://support.microsoft.com/kb/308001
You'll need to handle parsing the request and serializing the result yourself. It's probably much better to create a web-api facade in front of your services than trying to do it manually.
I have written a MVC web application that is used on our corporate intranet. We also have an MVC web site that is a seperate web application that is used by our customers. For our website to talk to our intranet systems database I have written a c# web service to access it.
The problem I have now is in the intranet application I have a complex routine that does some calculations that I now need in the web service for the website to do the same thing. I do not want to copy the logic and have it repeated in 2 locations for obvious reasons, so I need the web service and web application to share the same code base. I know this is possible but what is the best was to go about the use of application variables stored in web config files. For example if I move the code out of the intranet app and into a class library I will loose the functionality of being able to access the webconfig file, so where do I put these variables?
Any Suggestions on the best way to do this?
I will loose the functionality of being able to access the webconfig
file, so where do I put these variables?
You won't loose that ability. Every part of your application can access the configuration file, for instance by using the ConfigurationManager.AppSettings property.
Put the shared code in a class library that is referenced from both the web site and the web service.
We are interested in adding url rewrite rules programatically from our c#\asp.net 3.5 application to our iis 7.5 web server.
Is there any API for this, or should we just write into the web.config?
Some background: we are developing a hosted CMS that will host multiple websites, each website with it's own custom url rewrites.
This means that we should also be able to handle hundred thousand url rewrite rules - if you are aware of any limitaion of the IIS url rewrite module regarding this - please say so!
important note: we can't use the RewritePath c# method because we are rewriting to different application(seperate dlls with seperate web.config files).
Thanks in advance,
Eytan.
In a fairly standard fashion, I created a Web Reference to a SOAP service in Jira for an extension that I'm building (Jira is an issue tracker for those unfamiliar with it). Visual Studio auto-generates a .Settings file and an app.config that contains the web service URL.
Since I'm developing an extension/plugin to an ALM product we're building, the consumer of the extension will be the one who ultimately decides where this web service points to, because it will be integrated with the consumer's instance of Jira. Assume that the web service URL would be stored and pulled from a database.
How can I get the auto-generated service to use a URL from a database instead of from the generated app.config?
Note: we are using v2.0 of the framework, so WCF is not an option.
Even in the 2.0 web service you should be able to change the "Url" property of your web service proxy to the value you desire.
Use the constructor of the client that admits the uri.
How can I either create a new website or add a host header to an existing IIS 7 server from code?
I have looked and have not been able to find a working example?
One solution would be to create a custom HttpModule that does the work for you, however it does require you to be have a DNS that supports wildcards (*). If your DNS does not support that, you might look into managing your own DNS.
That said, here's a good post on creating an HttpModule that parses the "subdomain" passed in and forwards the traffic to the appropriate spot. He's using a search mechanism [to locate content with keywords matching the subdomain], but it can be modified for you own needs.
http://codebetter.com/blogs/brendan.tompkins/archive/2006/06/27/146875.aspx
[EDIT]
Another solution would be to find a DNS provider that offers a programmable DNS service, perhaps through a web service. You would then programatically add a subdomain to that DNS when needed from your application. That's a super simplified explanation, and doesn't take into account your business needs. Personally I prefer the HttpModule option for adding subdomains within an application as it requires less modification of the server(s) involved.
What version of .Net are you using?
If you are using .Net 3.0 or 3.5, and if you only need to configure IIS7 (not 6 or 5), check out the Microsoft.Web.Administration namespace -- it should have everything you need.
If you are using an older version of .net, have a look at WMI.
I don't have any WMI code for IIS 7 (we have a setup for an intranet application, but it uses IIS 6-compatible WMI). But, here's a link to a tool you can use for figuring out the WMI stuff: http://www.microsoft.com/downloads/details.aspx?familyid=2cc30a64-ea15-4661-8da4-55bbc145c30e&displaylang=en It will actually generate c# (or vb.net) code for manipulating WMI. For IIS 7, I think that the root WMI namespace is root\WebAdministration.
Also, have a look at this link, it might help Get to Know the IIS 7.0 WMI Provider Using CIM Studio