Silverlight - Check Website - silverlight

How do I check to see if a website exists at a URL in Silverilght? I basically want to ping a web page. However, the WebClient does not seem to work for me. Is there a way to check HTTP response codes in Silverlight? What does the code look like to ping a web site?
Thank you

You could parse out the results from http://downforeveryoneorjustme.com/.

Check out URL Access Restrictions in Silverlight, and here's an example for Using WebClient and HttpRequest.

Related

Showing pictures that uploaded on express server on react in a correct way

I built an express API and uploading images with multer .
in DB I save a post with image's name and I combine it with API link and show it in this way.
enter image description here
but my problem is , I think this is not a good way to show uploaded pictures and users can see API link ، isn't it bad? i mean in a security issues
can you help me please.
No, this really isn't an issue. There isn't any problem with people knowing your API URL. If someone uses something like postman to intercept the request, they'll find it out either way. You should however secure your API if there is important data on it.

"Cross-origin-request blocked". How to overcome that?

When I am calling rest services using ionic and angularJS It's getting "Cross-origin-request blocked". How to overcome that?
Thank you.
Better to Add https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en to your chrome extension.
<cfheader name="Access-Control-Allow-Origin" value="*">
<cfheader name="Content-Type" value="text/javascript">
You will set above text on your server page that means which page you want access from remote. And one more thing i am using coldfusion server so above code looks in cf code format. So you will change syntax which server you have use.
A cross-origin request is a request from one domain to another. For security purposes you cannot get around that unless you control the server of the receiving domain. To solve your issue you must, therefore, make the request from and to the same domain. For more information, see: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
You can bypass them in certain web browsers.
https://www.thepolyglotdeveloper.com/2014/08/bypass-cors-errors-testing-apis-locally/
Chrome has been most successful for me.

Handling Google clientLogin Captcha Example

I have a desktop application.
I try to perform authentication using
http://code.google.com/apis/accounts/docs/AuthForInstalledApps.html
However, whenever I get a Captcha challenge, I use a HTTP GET request (I test using web browser) to get the image to present to user.
https://www.google.com/accounts/Captcha?ctoken=Y-DrsDJRiWNOP3gR7fq0PAq4Yxvi3UXewu7P7jgAKjk0eZKQ358nbh27-JZ3-nlzXvfKOD3JvZNXwmlRunyz8jPKzqmkOLw2LYb3ZWjg-tE%3A0gMUFttsSH7QwganSJd1aw
However, I always get the images :
Sorry, we are unable to handle your
request at this time. Please try again
later.
Any idea what I had did wrong? Thanks!
I had solved the problem, please refer to code
http://jstock.cvs.sourceforge.net/viewvc/jstock/jstock/src/org/yccheok/jstock/gui/Utils.java?revision=1.86&view=markup (See getCapchaRespond method)
http://jstock.cvs.sourceforge.net/viewvc/jstock/Cloud/src/java/org/shuwnyuan/cloud/Authenticate.java?revision=1.2&view=markup

Using a subdomain to identify a client

I'm working on building a Silverlight application whereas we want to be able to have a client hit a url like:
http://{client}.domain.com/
and login, where the {client} part is their business name. so for example, google's would be:
http://google.domain.com/
What I was wondering was if anyone has been able, in silverlight, to be able to use this subdomain model to make decisions on the call to the web server so that you can switch to a specific database to run a query? Unfortunately, it's something that is quite necessary for the project, as we are trying to make it easy for their employees to get their company specific information for our software.
Wouldn't it work to put the service on a specific subdomain itself, such as wcf.example.com, and then setup a cross domain policy file on the service to allow it to access it?
As long as this would work you could just load the silverlight in the proper subdomain and then pass that subdomain to your service and let it do its thing.
Some examples of this below:
Silverlight Cross Domain Services
Silverlight Cross Domain Policy Helpers
On the server side you can check the HTTP 1.1 Host header to see how the user came to your server and do the necessary customization based on that.
I think you cannot do this with Silverlight alone, I know you cannot do this without problems with Javascript, Ajax etc. . That is because a sub domain is - for security reasons - treated otherwise than a sub-page by the browsers.
What about the following idea: Insert a rewrite rule to your web server software. So if http://google.domain.com is called, the web server itself rewrites the URL to something like http://www.domain.com/google/ (or better: http://www.domain.com/customers/google/). Would that help?
Georgi:
That would help if it would be static, but alas, it's going to all be dynamic. My hope was to have 1x deployment for the application, and to use the http://google.domain.com/ idea to switch to the correct database for the user. I recall doing this once when we built an asp.net website, using the domain context to figure out what skin to use, etc.
Ates: Can you explain more about what you are saying... sounds like you are close to what I am trying to come up with. Have you seen such a tutorial for this?
The only other way I have come up with to make this work is to have a metabase that when the user logs in, it will switch them to the appropriate database as required... was just thinking as well that telling Client x to hit:
http://ClientX.domain.com/ would have been sweeter than saying to hit http://www.domain.com/ and login. It seemed as if they were to hit their name, and to show it personalized for them right from the login screen would have been much more appealing for the client base.
#Richard B: No, I can't think of any such tutorial that I've seen before. I'll try to be more verbose.
The server-side approach in more detail:
Direct *.example.com to the same IP in your DNS settings.
The backend app that handles login checks the Host HTTP header (e.g. the "HTTP_HOST" server variable in some platforms). That would contain the exact subdomain.example.com that the client used for reaching your server. Extract the subdomain part and continue...
There can also be a client-side-only approach. I don't know much about Silverlight but I'm assuming that you should be able to interface Silverlight with JavaScript. You could read document.location with JavaScript and pass it to your Silverlight applet, whereon further data fetching etc. logic would rely on the subdomain that was passed in by JavaScript.
#Ates:
That is what we did when we wrote the ASP.Net system... we pushed a slew of *.example.com hosts against the web server, and handled using the HTTP headers. The hold-up comes when dealing with WCF pushing the info between the client and the server... it can only exist in one domain...
So, for example, when you have {client}.example.com and {sandbox}.example.com, the WCF service can't be registered to both. It also cannot be registered to just *.example.com or example.com, so that's where the catch 22 is coming in at. everything else I have the prior knowledge of handling.
I recall a method by which an application can "spoof" another domain name in certain instances. I take it in this case, I would need to do such a configuration? Much to research yet I believe.

How to do crossdomain calls from Silverlight?

What's needed to succesfully make a crossdomain call from Silverlight?
If I understand your question correctly you would need to have a clientaccesspolicy.xml file in the domain web root of the server that you wish to call (ie www.example.com/clientaccesspolicy.xml) that defines that it is ok for services from other domains to call services on that domain.
Read the How to Make a Service Available Across Domain Boundaries MSDN article for more detailed information.
See Jon Galloway's blog post on this as well
http://weblogs.asp.net/jgalloway/archive/2008/12/12/silverlight-crossdomain-access-workarounds.aspx
Intellisense helper file and walk-through: http://silverlight.net/learn/learnvideo.aspx?video=47174
Maybe also check out JSONP http://www.west-wind.com/weblog/posts/107136.aspx for example this is how you can get Twitter updates in JavaScript on the client side even though Twitter is on a different domain than you web page.

Resources