I have searched around for the answer to this but cant find anything that fits my exact scenario.
Currently have the below set up :
RootApplication(sitea.bla) .NET 3.5
- ChildApplication (sitea.bla/service1) .NET 3.5
The root application is being rewritten in .NET 4.5 but the service1 application will not be being updated in this current phase and will be removed as an child application.
I have moved the service1 application to a sub domain (service1.sitea.bla)so it can run in an legacy application pool.
This works perfectly though I have multiple other applications/services/clients that reference the original endpoint. I have set up a IIS redirect which works perfectly in the browser
sitea.bla/service1/exampleservice.asmx gets redirected to service1.sitea.bla/exampleservice.asmx
Though when making a call through a client application it fails unless I manually change the endpoint to the new sub domain . I have also tried achieving through a reverse proxy.
What is the best method to achieve this without manually changing all the endpoints to the new sub domain?
You need to setup correct rewrite rule:
1) You need to install ARR module (you need it, because you rewriting requests to different application)
2) In IIS manager you should enable reverse proxy
2.1) On server node click "Application Request Routing Cache"
2.2) Click "Server proxy settings" and click "Enable proxy", then "Apply"
3) In web.config of application sitea.bla add this rewrite rule:
<rule name="rewrite service1" stopProcessing="true">
<match url="^service1(.*)" />
<action type="Rewrite" url="http://service1.sitea.bla{R:1}" />
</rule>
4) Try to make a call to sitea.bla/service1/exampleservice.asmx
Related
I am trying to call a webservice to get information about specific objects. It works perfectly fine in my test WinForms application, basically after I added the service reference I did not have to do anything else than creating a local client in my C# class, setting up the input parameters and calling the method that was in the documentation and I received the response I wanted. Very simple webservive, no https, no magic.
I copied my code to my MVC web application, I made sure to copy EXACTLY the same url, web.config settings (bindings, endpoints), I even updated the service reference many times, but in MVC it does not work. The error message says:
"There was no endpoint listening at 'webservicename' that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details."
The inner exception is:
"No connection could be made because the target machine actively refused it 127.0.0.1:8888"
I have set up my hosts file, because I am using Local IIS and wanted to use the websie's name in the url, so I have this in my hosts:
"127.0.0.1 www.mywebsite.local"
I have a feeling that either my firewall or app pool setting causes this problem, but I could not figure out which one. Once again, the webservice is working perfectly fine from my basic test WinForms app.
I tried to change the Identity of my app pool to something else than ApplicationPoolIdentity (I tried NetworkService, LocalService, LocalSystem), but it did not help.
.Net version is 4.5 in WinForms and 4.5.1 in MVC.
Any ideas?
Edit:
It looks like there is a problem with the proxy settings. In the MVC web.config I had the following section:
<system.net>
<defaultProxy enabled="true">
<proxy proxyaddress="http://127.0.0.1:8888" />
</defaultProxy>
I do not know why, but when I set it to false, the problem goes away...I am not an expert of proxies. Does it mean I have to add special settings to my firewall?
I try to redirect www.myDNNSite.com/hastinfo/[...] to http://172.16.244.43:83/[...] in DNN 7.x
To do that, I added a rule in SiteUrls.config as this blog showed https://bertcraven.wordpress.com/2008/05/21/quick-n-dirty-redirects-in-dotnetnuke/
<RewriterRule>
<LookFor>[^?]*/hastinfo/(.*)</LookFor>
<SendTo>http://172.16.244.43:83/$1</SendTo>
</RewriterRule>
This not work if there is a . after hastinfo, so:
www.myDNNSite.com/hastinfo/test -> OK 172.16.244.43:83/test
www.myDNNSite.com/hastinfo/myhandler.axd -> KO error 404 and no redirection
It seems that DNN make something with URL if there is a . founded.
How to make my redirection working even if a . (dot) is present in url ?
EDIT:
My objective with this redirection is to have the same end point for my dev and production environment. I have three server on the front end and the Web Service behind the www.myDNNSite.com/hastinfo point to three differents servers to load balance the charge.
Before update to DNN 7.X, I was using ManagedFusionRewriter that make the job.
But It is not updated from 2009 and now with IIS 8.5 I look a better way to make this redirection from a config file.
EDIT 2:
I try to add IIS Mod Rewrite in my IIS 8.5 and write in Web.config:
<rewrite>
<rules>
<rule name="Imported Rule 101" stopProcessing="true">
<match url="^hastinfo/(.*)" />
<action type="Rewrite" url="http://172.16.244.43:83/{R:1}" appendQueryString="true" />
</rule>
Without success ... here the Failed Tracing:
Using IIS Redirects in combination with the DNN Friendly Url providers is often a recipe for disaster sadly.
In this case, the reason that you are having issues more than likely is that the .axd is being captured by the ASP.NET process and that is preventing the re-writing from happening.
Based on what you are looking to do, can you explain a bit the true goal? The reason for this answer rather than a "do this" is that redirecting with DNN to a non-standard port is also going to cause issues as there is a setting for "usePortNumber" in the web.config that you will want to have on if using a non-standard port.
I finally found a way to make it works.
Thanks to: http://blogs.msdn.com/b/asiatech/archive/2011/08/25/return-404-4-not-found-when-url-rewrite.aspx
You need to install Application Request Routing and enable Proxy, then it will work with URL rewriting to remote servers (regardless where or what they are) since the Routing will take care of that.
http://www.iis.net/download/ApplicationRequestRouting
I'm new to URL Rewrite.
I created a WCF Rest service, and I'm trying to set a rewrite rule that will allow invoking the service when the svc extension is hidden.
I have a method named "Test" on that service, that I invoke successfully with the svc extension present.
What I did:
Created a rule in the web config:
Checked the Rule shows in IIS under ReWrite features.
Validated it works as I expect by clicking the "test pattern" button and entering the URL details:
Did IISReset (Several times).
I'm getting a 404 when trying this URL:
http://localhost/WcfTestApp/Service1/Test
Additional Stuff:
I also enabled "Failed Request Tracing Rules" But I see no logs created in the folder.
Any Ideas why it isn't working as I expect?
Thanks in advance for any help.
What I did to resolve it:
I fixed the failed request tracing log files not appearing, turns out you need to configure in the IIS settings the status codes for which the trace should occur, as it's not smart enough to select all by default.
Then via the trace file (which I opened in IE), I noticed my rewrite rule needed a slight modification, as I was able to see what URL I got, and what it was rewritten to (which did not work).
Eventually, that's what I used.
<rule name="RemoveSvcExtension" stopProcessing="true">
<match url="^(.*)Service1/(.*)$" />
<action type="Rewrite" url="{R:1}Service1.svc/{R:2}" logRewrittenUrl="true" />
</rule>
I am using a WebForms application with some MVC components added in. The idea is to move more and more of the app over to MVC but there is no way it can be transitioned all at once. For various reasons I cannot control it must use ASP.Net 2.0 and MVC 2.0 since those are what ship built-in. I must also support IIS 6 and IIS 7.
First, I am well aware of the problems with extensionless routing and I am not attempting to use it so there are no issues with wildcard mappings, etc. I first attempted to use my routes ala "{controller}.aspx/{action}/{id}" but after banging my head on the wall I switched to "{controller}.mvc/{action}/{id}" but am having the same issues.
Second, I cannot get this to work even in IIS 7 Integrated mode on my dev machine, let alone Classic mode or IIS 6. It all runs correctly under Cassini but once I deploy to IIS 7 the MVC components break. Since this is on my dev machine I know ASP.Net is registered with IIS correctly and I can see all the inherited HTTP handlers in the control panel (eg: ASPX maps to PageHandlerFactory).
Symptoms:
All ASPX WebForms requests work perfectly.
An MVC requests to just the controller with no action/id specified get routed to MVC and execute properly as well.
Any request to an MVC route with an action or id immediately returns a 404. It is as if IIS thinks the ".mvc" extension is part of the folder path so it ignores the HTTP handler and returns a 404.
In other words:
/app/WebForm.aspx - HTTP 200 OK, executes WebForm.aspx.cs code-behind
/app/Fancy.mvc - HTTP 200 OK, executes /Controllers/FancyController.cs, Index method
/app/Fancy.mvc/DoThingy - HTTP 404 NOT FOUND, even though FancyController has DoThingy method
Bad Solutions: I have tried things like setting runAllManagedModulesForAllRequests but not only is that bad for performance it also breaks my Web Forms as well. Even when I set it to ignore all routes with .ASPX in them they still break.
I cannot use wildcard mapping so that is no help.
Other Details:
I setup my HTTP Handler in web.config/system.WebServer. It is the first handler listed.
<add name="MvcRoutingHandler" preCondition="integratedMode" verb="*" path="*.mvc" type="System.Web.Routing.UrlRoutingHandler, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" resourceType="Unspecified" />
It doesn't seem to matter what handler I specify or what options - IIS just doesn't seem to be examining any of this configuration (again because it seems to think the Fancy.mvc part of the path is a directory name, doesn't find that directory, then bails).
My routes:
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.IgnoreRoute("{resource}.asmx/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspq/{*pathInfo}");
routes.IgnoreRoute("{resource}.svc/{*pathInfo}");
routes.MapRoute("Default",
"{controller}.mvc/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
Update: I tried using IIS 7 Classic mode; I then added a .mvc mapping in the IIS Manager pointing at the asp_net ISAPI dll and got the same result
OK just so others don't look foolish, it turns out that this was a problem with URLs... the URL was being sent to the root of the site, not the app directory. I should have checked that to begin with. I didn't think this was the problem because when I manually typed the URL into the address bar it worked on the Index but the action method required HttpPost, so it was a combination of factors that made the script and manually-entered addresses spit out the same error message.
For anyone else mixing WebForms and MVC, double and triple-check that your URLs are correct. Here is some code I am now using on the WebForms master page so my client-side JS can know where to route MVC requests:
string baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
if (baseUrl.EndsWith("/")) baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
baseUrl = baseUrl + ResolveUrl("~/");
Page.ClientScript.RegisterHiddenField("BaseUrl", baseUrl);
Is it possible to force WcfSvcHost (which is executed automatically when I do an F5 or when I am debugging another project in the solution) to use a custom ustom service?
I have my custom service host working great in my asp.net Host container by using a service factory which in turn calls the Custom Service Base.
But when WcfSvcHost executes it's not using my custom ustom service.
Is this possible?
If not, what are my alternatives? I presume I must uncheck "Start WCF service host when debugging a project in another solution" which is in the WCF Options in app properties but then I must create a console Host container?
And I can't get the console host container to automatically execute each time I am debugging something else?
I notice this under DEBUG in app properties (maybe I can use something like this to force the loading of the custom servicehost)
/client:"WcfTestClient.exe"
The problem being is that I have my custom ServiceHost inject some UNITY (IOC) stuff, here the overriden method ... so it must execute otherwise it fails.
protected override void InitializeRuntime()
{
Bootstrapper.ConfigureUnityContainer();
base.InitializeRuntime();
}
I was trying exactly the same thing for exactly the same purpose (;-)
I thought I found a solution by not using physical .svc files anymore (which contain the custom host factory when hosting in IIS), but moving this info to the .config file instead:
<serviceHostingEnvironment aspNetCompatibilityEnabled="false">
<serviceActivations>
<add relativeAddress="~/Services/NaisTime/NaisTimeService.svc" service="Nais.Time.Services.NaisTime.NaisTimeService"
factory="Nais.Time.Services.NaisServiceHost.NaisServiceHostFactory, Nais.Time.Services" />
<add relativeAddress="~/Services/Northwind/NorthwindService.svc" service="Nais.Time.Services.Northwind.NorthwindService"
factory="Nais.Time.Services.NaisServiceHost.NaisServiceHostFactory, Nais.Time.Services" />
</serviceActivations>
</serviceHostingEnvironment>
It works for IIS, but putting the same entries in the app.config file of my Service Library project does not make SvcWcfHost use this.
I guess I am not getting my relativeAddress right.
Anybody any experience with this?
kr,
Michel Liesmons.
I don't think you can do that - you'll need to host in IIS or create your own, customized service host.