Silverlight WebApp Calling Webservice in the same solution - c#

I have a website solution that is composed of a Silverlight Project and an ASP Site that contains an asmx Webservice.
The Silverlight project calls various methods in the Webservice, and this works fine on my home PC.
When I publish the site (using 123-Reg if that makes a difference), it appears that the Silverlight app is no longer able to call the webservice. I have tried debugging the app by pointing my local version of the site to my published webservice and I get a "policy" issue.
I know that 123 Reg have .Net 3.5 running on their servers, so I would assume that the site should "just work" when I publish it. Am I making a hugely stupid assumption there? Is there anything that I can do to change the "policies" within my app? Or is there another way around what I am trying to do? I need to keep the webservice, as I want for it to be used from other places, and don't really want to duplicate code and create the same methods within the Silverlight project.
Thanks

Soundlike you are hitting a crossdomain issue, though you shouldn't really.
I would stick a clientaccesspolicy.xml in the root of you web server.
There are loads of questions on SO if you need examples or MSDN

Related

Publish just one webform? Or precompile just one webform?

I'm sure this isn't the first time someone asks this, but I tried doing a search and found nothing.
We have an issue with a website, and we've narrowed it down to a timeout issue with an email being sent. So I created a simple webform that sends a test email and I would like to reproduce the error with this new webform..
The issue is that since we publish the website, what's deployed to the production server are precompiled files. I don't want to publish the whole site again just to include one webform with two controls.
How can I just publish one webform? Or how can I precompile just one webform? I don't want to publish the whole site.
Thanks.
You really didn't display any code for us to evaluate perhabs we might see the very source of your problem from the method you're using to send the email.
From experience, using SMTP in ASP Webforms usually crashed the app at some point in the lifecycle. The issue might be from time-outs or from the security configuration of your Website or the hosting enviroment.
I'll recommend you integrate the use of Email APIs to avoid these issues. Sendgrid is a good choice.
Secondly, it appears you have a small test Webform project where you expect to encounter the result again and to maybe adequately analyse the error. I recommend you do not need to deploy this test Webform to your hosting environment because as it would replace the existing site there. While you have the option to pre-compile the site before publishing via FTP, Web deploy does the whole work for you automatically.
It's better you create a different enviroment for testing apps to prevent interference with the live version.
Once you write some server side code, you need the recompile your website and replace the .dll in your bin folder.

How to post to a web service that has implemented Single Sign On?

(sorry in advance this got a bit long)
The web service in question is running on IIS that has enabled Windows Integrated Authentication.
The development environment is C#, Visual Studio 2008. I can use 2010 if I need to. My old projects are still in 2008.
The two applications I have are my 'fiddling around apps'.
One uses the standard methodology of calling a web service (i.e. adding the web reference, built the proxy classes, etc).
The other basically takes an external XML file and does an HTTP post to the URL (I built it before I knew of the existence of SOAPUI).
So now the web service is going to be behind SSO and I'm trying to figure out how to call the web service with these two different applications.
I assume there is two different ways to do it. The standard way is just to add the line
myproxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
This works great in my standard application.
How would I go about doing this manually in the HTTP post application?
I assume the same line of code would work on the HttpWebRequest object, but I would like to give it a shot manually.
thanks and again sorry for the length.
lee

ASP.NET Web Service parser error on server, not locally

EDIT2
Looks like I can't read properly, disregard this post, I will try to make a WCF service instead.
Thank you
EDIT:
Ok it seems I should start learning MVC instead. I tried getting into it before when I could't get this to work but maybe I didn't try hard enough because I already completed my web services and didn't feel like starting over before I knew if the problem was trivial.
For those who are interested:
What I am actually trying to accomplish is to create a database with a dozen different highscore tables which I will be able to retrieve from my Android app as JSON. So far I have an XML database and a webmethod for asking if a score is in the top 50 on a specific highscore table. One for submitting your score, and one for retrieving the entire highscore to show in the app. I also have a simple interface for adding, removing etc from the database.
Updated question: Will I be able to reuse some of my code if I create an MVC project and how do I put said project on the server? can it be done with an FTP client or do I need to use Web Deploy, IIS or web matrix or some other software? and what are the requirements of the server?
Thank you so much for the help :)
----------Original Post--------------
Recently I have been trying to learn how to create a web service in Microsoft Visual Web Developer (2010 express on win7 64bit) in a web application. I have a few very simple JSON web methods and when I run the project locally from Visual Web Developer it works like a charm, they return the correct values etc.
But when I transfer the project to my windows server running .NET 4.0 (which is the same as my target framework in this project) I can't access the web service anymore, the .aspx web pages work great but the .asmx web service shows the following error:
(I can only post two hyperlinks yet so I removed this image)
That line 1 is the only line in the .asmx file btw. I have tried putting the Namespace.Classname there instead but the error remains. (Test.DBWebService instead of just DBWebService)
I haven't changed anything in the code, this exact code does work on my computer. I have tried things that helped others with similar issues, like the build options:
Before running startup page: Build Web Site
Target Framework: .NET 4.0
Build Web Site as part of a framework Checked
which I assume should be configured like that.
My web.config looks like this:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation targetFramework="4.0"/>
<customErrors mode="Off"/>
</system.web>
<appSettings>
</appSettings>
<system.serviceModel>
<bindings/>
<client/>
</system.serviceModel>
</configuration>
This is the .cs file for the web service and an example method which works locally but can't be accessed on the server.
http://i.stack.imgur.com/4T6pq.png
What could possible create this problem? Am I missing something vital here because I am not very experienced. I have tried for days to get this done and even asked my web hosting company but they said they don't help with programming related issues.
If you are just now learning web services, then you should stop right now. You've made a major mistake.
You are using "ASMX Web Services", a technology which is all but obsolete. No new development should be done using ASMX unless there is no other choice.
Another mistake you are making is in using the web site "project". I strongly recommend you not use those for anything other than simple sites, and you might want to avoid them for that purpose in any case. Among other things, they have this precise issue with not building what you think they should build when you think they should build it.
Use a web application project instead, using "Add New Project" instead of "Add New Web Site".
Most probable causes of your issue are:
- wrong configuration of the site (application) within the IIS. My guess is that you are deploying onto an application but for some reason the application is not correctly created and the ASP.NET is unable to initialize the /bin folder where the binaries should exist
- wrong configuration of the IIS/ASP.NET. Find another machine with similar configuration and check your site there. If it works correctly, you could go back and try to find/resolve issues with your local ASP.NET configuration.

How to configure and debug a web application using MVC and WebForms

I have an existing ASP.NET web application that I'm converting to MVC 1.0. The site started out with one goal. However, over time our sponsors are asking for more functionality and it is obvious that MVC would be our best route due to the new requirements. I've dabbled in MVC over the last couple of months and have a pretty good grasp on it all works. The problem that I'm faced with now is that the meat of our existing web application makes extensive use of a 3rd party tool that only works within ASP.NET WebForms.
The solution that I'm working on is to have two web applications running on the server. The one application would be our existing WebForms app and is solely used to expose the above mentioned 3rd party tool's functionality. The other application will be our main portal that will act as the new site. When the user wishes to interact with the 3rd party tool, I want to be able to load an iFrame on the appropriate Views that links the user to the other application and will then allow them to interact with the WebForms site. Does this sound crazy?
The number 1 problem that I'm faced with right now is how to configure my solution make the MVC application talk to the WebForms application. Every time I run the solution, a different port number is assigned to the two applications and I can't figure out how to configure my iFrame "src" properties correctly. Of course, I can't add the WebForms application to my MVC applictions' References, so I'm stumped!
Any help would be greatly appreciated...
If the port issue is the only problem, you can run both of them in IIS under a fixed virtual application.
But the ASP.NET development server also has the feature to fix the port to a specific number and not randomize it each time.

Publishing a .NET C# website to an external server

I have just completed my first aspx/c# project using Visual Web Developer Express and consuming some custom controls and external web services. It runs fine on my development machine.
If I now want to test this on a shared hosting account, do I just upload all the files with the current project structure? Will there be any problem uploading the DLLs to a shared Windows hosting account? Anything I should be aware of or changes to be made to the code? Can anyone recommend a cheap and good provider (this is just for testing - no mssql required yet).
Thanks!
Does visual web developer have a "publish website" menu item under the Build menu?
If you want to pre-compile your site and publish it with all dependencies the easiest way I've found. You can then choose to publish it to either an FTP site or the file system. I usually choose the filesystem and then FTP it up myself to make sure I don't overwrite any config files.
If I'm working on a low volume site for a client and performance isn't a problem, I'll just upload my working directory right up to the server so I don't have to deliver the source code separately and I know they won't loose it.
Oh, and one other thing, if you don't configure it special, I would expect you will have to upload your site to the root directory of your hosting account. GoDaddy does have the ability to specify certain directorys as their own ASP.NET application. If you do that you can put your app in a sub-dir of your choosing.
-Al
It would depend on your website provider. You need to get one that supports the .NET runtime. Once you have that, then you simply upload your code and all should work. I personally use www.godaddy.com. You can see an example ASP.NET site hosted by them at www.chessbin.com.
I hope this helps.
Adam
The hosting companies may vary on what they require, but I would think a simple xcopy deploy would be sufficient for most. Here's a link to one that seems to have good prices (disclaimer: I have never used them)
http://www.reliablesite.net/v3/index.asp

Categories