Silverlight application with external web service references - asp.net-mvc

I have a standalone Silverlight 4 application that has a service reference from a WCF project different from the web site where the SL object is stored (used). The service url are hardcoded and the web site where my SL object is stored (used) was not generated using the project wizard (in which you create the Silverlight project and its web site).
So, my questions are:
how could I stop using hardcoded url values from SL?(from the
serviceReference.client file)
how could I fix the Wcf service port value? (everytime it chooses a different port value: like localhost:randomPort/... to keep the randomPort fixed )?
how can I debug the SL project once it is loaded? (followed the steps from here but it keeps throwing the error 2104 unable to download the silverlight client. check your web server settings)

For Hardcoded URLs:
var serviceClient = new YourServiceReference.ServiceClient();
serviceClient.Endpoint.Address=new EndpointAddress("http://yourservice.com/Service.svc");
How could I fix the Wcf service port value?
In WCF Project properties go to WEB ->Servers -> Use Visual Studio Development Server ->Specific Port [add port you want] or you can setup your service on your local IIS

Related

Hosting two websites in a same IIS server using two ports

I have an IIS server which is hosted one website using default port number 80 and it is bind to mywebsite1.com:80. It is able to view using its domain mywebsite1.com without any issue. Now I hosted another website using port no 70 and need to bind mywebsite2.com to it. But since DNS record not supporting to the port numbers, I am able to view my newly hosted website using the URL mywebsite2.com:70. Is there any way to avoid putting port no there and access the website using its domain mywebsite2.com directly.
Windows Version : Windows Server 2016,
IIS Version : 10.0.14393.0
Thanks #Dusan Bajic and #Lex Li for the guidance. I was able to solve this issue by ticking the “Require Server Name Indication” in IIS site bindings.
Reference : https://www.sherweb.com/blog/cloud-server/host-different-ssls-on-one-ip-with-iis-8-sni/
Then i set up the HTTP/HTTPS redirect in IIS and now everything working fine,
(https://www.namecheap.com/support/knowledgebase/article.aspx/9953/38/iis-redirect-http-to-https)

Issues with running remote MVC app within local asp page

I have a classic asp site, and an MVC web app. I have both of them hosted locally as localhost in my dev environment. I also have both of them set up on a remote server.
Below is a list of URLs of my apps:
classic asp site hosted locally: http://localhost/AspAppName/
classic asp site hosted on remote server (IIS): http://ServerName/AspAppName/
MVC web app hosted locally: http://localhost/MvcAppName/Dir/SubDir
MVC web app hosted on remote server (IIS): http://ServerName/MvcAppName/Dir/SubDir
What I am trying to do is have my MVC app ran within iframe placed on one of the pages of my classic asp site.
when I run my local version of MVC app within iframe of my locally ran classic asp site, everything works. In such case I use "http://localhost/MvcAppName/Dir/SubDir" as the URL to execute within my iframe and the iframe is on "http://localhost/AspAppName/SomePage.asp"
when I locally run my remote version of MVC app within iframe of my locally ran classic asp site, I get the following error:
"This content cannot be displayed in a frame.
To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame"
In such case I use "http://ServerName/MvcAppName/Dir/SubDir" as the URL to execute within my iframe and the iframe is on "http://localhost/AspAppName/SomePage.asp"
The error shows up in IE. In Firefox and Chrome, the iframe area just ramains blank.
Just for testing purposes and to see if these are some cross-domain limitations/settings I tried putting my classic asp site hosted on remote server (http://ServerName/AspAppName/RandomPage.asp) within iframe of my classic asp site hosted locally (http://localhost/AspAppName/SomePage.asp). In such case, I do not see any errors and the local asp site displays iframe content with remotely hosted asp page without any issues.
Here is some application pool information from IIS on my local machine:
MvcAppName: .NET CLR version: v4.0, Managed Pipeline Mode: Integrated; Identity: ApplicationPoolIdentity
AspAppName: .NET CLR version: v2.0; Managed Pipeline Mode: Classic; Identity: NetworkService (!, ?)
Here is some application pool information from IIS on my remote server:
MvcAppName: .NET CLR version: v4.0, Managed Pipeline Mode: Integrated; Identity: ApplicationPoolIdentity
AspAppName: .NET CLR version: v2.0; Managed Pipeline Mode: Classic; Identity: ApplicationPoolIdentity (!, ?)
I strongly appreciate any advice on what might be causing my issue with nesting my remotely ran MVC app within iframe of my locally ran asp site.
Sounds like you need to return an X-Frame-Options header from the site that cannot be displayed in the iframe. This page shows the available options and how to set it up in various servers, including IIS.
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options
It turned out the X-Frame-Options setting was being overwritten automatically. To turn it off, I had to add the following line to Application_Start in the Global.asax.cs.
AntiForgeryConfig.SuppressXFrameOptionsHeader = true;

MVC Web App using Web API do not work after deploying on IIS

I have created Web application using asp.net MVC architecture.
I have used Web API for getting data from database. Both Web application and Web API are in same project. I have not published Web API separately on IIS.
When I am debugging or running the application through Visual studio it works properly. I have used below code to get data from Web API URL
TODOINfo[] lstToDoInfo = httpClient.GetAsync("http://localhost:65373/api/RESTApi").Result.Content.ReadAsAsync<TODOINfo[]>().Result;
In Above function I am passing url which consist of localhost plus fixed port number. Above code is working fine when running through in Visual studio.
I have published the same code on IIS by doing below changes.
TODOINfo[] lstToDoInfo = httpClient.GetAsync("http://" + sBaseUrl + "/api/RESTApi").Result.Content.ReadAsAsync<TODOINfo[]>().Result;
sBaseUrl value is "localhost".
After Browsing the application on internet explorer getting following error.
No MediaTypeFormatter is available to read an object of type 'TODOINfo[]' from content with media type 'text/html'.
Any information or suggestion regarding above problem is highly appreciate.
Try changing sBaseURL to "localhost/" +yourwebsite
another option would be to change: sBaseURL to: servername/yourwebsite

Connecting between IIS Express and Jetty on Azure Cloud Service Virtual Machine

I have an Azure Cloud Service Virtual Machine with 2 server:
Java project using Jetty server at http://localhost:8999
ASP.NET MVC project using IIS Express at http://localhost
I am using Http request to make connection between 2 server.
In my VM, inside ASP.NET MVC project, I use http://localhost:8999 to get data from Jetty server. It works perfectly with short response time (from 100ms to 6000ms).
However, when I access the IIS Express via Internet using http://mydomain.cloudapp.net. It does not work anymore.
Then I change my config file in ASP.NET MVC project to use http://mydomain.cloudapp.net:8999. It works but with long response time (from 15s to 40s). This is because of my slow internet connection.
My question is:
If I access IIS Express via Internet, to avoid external internet connection, is there any solution which let IIS Express know that it's target is local?
Which means I can still use http://localhost:8999 in my config file in ASP.NET MVC project, and it still work if I access IIS Express via Internet not only via localhost.
The main question is how you connect between the two servers? From the client side (JavaScript) or the ServerSide (Controller action/private method).
From what you describe it seems that you make XMLHttpRequest (JavaScript, AJAX, jQuery, etc.) call from your client side directly to your Jetty Server. In order to avoid roundtrips, you have to change this and make XMLHttpRequest to Your Server (MVC), then on the MVC backend (Controller action, or private method, or Repository) make the Jetty server call and transparently return the answer to the calling client.
You can also try tweaking your Jetty Server settings to allow for longer script execution.

ASP.NET MVC and host problems

Hi,
I have done the following :
Start Visual Studio 2010
New Project > ASP.NET MVC
Default ASP.NET MVC project generated by VS2010
Add a couple off simple buttons on the first page
Start local IIS manager, Create a web application and point it to the ASP.NET MVC project
Set correct right on the ASP.NET MVC project folder(to the user running the thread pool in IIS7)
Browse site (http://localhost/MyTestSight/) and the first page is shown
Upload site to www.test.figurspel.net
Host sets the site to be runned on .NET 4.0
Browse www.test.figurspel.net and the site is not working?
The host has checked that tha Active Server Page is set to allow
Host has installed up to MVC 3
I could turn on the Browsable to see the file structure but this will not help to get the site running.
How do I get this asp.NET MVC web site running?
BestRegards
Is the application pool running in integrated mode the IIS site running under that application pool?
It's my understanding that if this isn't the case, the MVC site will not run.
Alternatively, have you tried this?
+1 Unicorn power HooooooO!!!!! Also I've always when hosting a site published the project to a different folder then setup the site via IIS from that folder hope this helps.

Resources