Problem passing querystring from from silverlight to http handler - silverlight-3.0

I am using Silverlight 3 beta and Visual Studio 2008 SP1 for this.
In the web application (Server side) I have a HTTP handlter ImageFetcher.ashx which expects an ID parameter from the query string and retrieves the data from database and writes it to output stream. This is working fine and I have tested it with a test aspx page adding a image control with src=ImageFetcher.ashx?id=44.
I also have a silverlight client navgatoin application in the same solution. I have the following image tag in my xaml
<Image x:Name="myImage" Width="400" Height="300" Stretch="Uniform" Source="/ImageFetcher.ashx?id=44"/>
When I run this app, it fails to retrieve the image. When I debugged the handler, I noticied that it is not getting any querystring parameter. if the change the image tag to use absolute URL as below it works fine again
<Image x:Name="myImage" Width="400" Height="300" Stretch="Uniform" Source="http://localhost:5573/ImageTest/ImageFetcher.ashx?id=44"/>
But I cannot use the absolute URL, what is wrong here? why the relative URL does not carry the querystring correctly to the server side?
Thanks
Shreedhar

I posted on Silverlight forums as well, but I'll copy it here too.
A relative URL is relative to the XAP - which is loaded on the client machine. Once the XAP is downloaded to the client, the loading ashx page will no longer be relative to the XAP and will therefore not be found. Once you make the url absolute, you are telling it to look on your local host [the exact location] for the loading page.

Related

Dynamic Image in SSRS report Image control not working

I have an Asp.net MVC 5 website that hosts a RDLC file. I want to call a controller action to render an image in the report. The Image control has "External" image source set. I have tried passing the URL as a parameter to the report and setting the image expression to that parameter. The image is blank. The HTML in the browser states "src=unknown". I have also tried hardcoding the expression. No image displays. When I put the URL in the browser, the image displays. The hardcoded URL is ="http://localhost:55426/image/showbarcode?id=69899694-6ce4-e811-80cc-78e3b50d083e". The website is not hosted in IIS. No errors are reported
This is the only report that is using external images. I did have to change the SSRS target server version to "SQL Server 2008 R2, 2012 or 2014". All the other reports render fine.
My coworker changed the report to get the image from the database. That fixed the problem.

asp.net mvc using HREF in application running on IIS

There is a partial view representing pager control (very similar to this) for blog content. Code generates HTML with references and href like, "/Blog/Posts/Page/1", "/Blog/Posts/Page/2" etc.
It worked absolutely fine on Cassini, but after I switched to IIS problems appeared.
IIS application running in virtual folder, so URL is
http://localhost/tracky
and blog area located,
http://localhost/tracky/blog
As I press on pager button, I recieve 404, because the URL would be
http://localhost/blog/page/3
Instead of
http://localhost/tracky/blog/page/3
My question is, how to handle such situation? how to change code generation to provide correct URL? how to make it work same - as root applicaton or application in virtual folder?
Source code is here
You need to generate your urls either by using ActionLink in your view, or using an UrlHelper in your href as follows: <a href="<%=Url.Content("~/blog/page/3")%>" ..>bla</a>. This will generate Urls that are adjusted accoring to your application root.
You should be using the following:
UrlHelper.GenerateContentUrl("~/Blog/Posts/Page/1");
The ~ allows the url to be resolved relative to the application path and should produce correct results in both cassini and IIS.

Running ASP.NET MVC application in a subdirectory, getting 404 errors

I have an application that uses ASP.NET MVC. I have it deployed to a Crystal Tech server (hence, no direct access to IIS control panel).
Initialy this was running in the root directory and everything was OK. The client then decided that it needed to run in a subdirectory. I moved the app there and the home index page comes up, but every other page tries to access the the controller/action/page/view in the original root directory. I don't understand this, since the references were all contextual (i. e. using ../controller/action as opposed to mysite.com/controller/action).
Am I doing something wrong here? What are my options?
Thanks,
James
I would use the UrlHelper to generate the links. This would ensure that they are relative to the application path.
Link Text
and
<img src="<%= Url.Content( "~/images/myimg.jpg" ) %>" alt="My Image" />

Where do .CAB files go on my web server?

I am working on an ASP Classic site that uses 3rd party ActiveX controls. I've never worked with ActiveX controls before and I'm not sure where to put the .CAB files on my web server to get them to install through IE when IE can't run the objects.
Could someone point me in the right direction?
The code in my page to load the object looks like this:
<object id="Printer" classid="CLSID:402C09CD-68ED-48B0-B008-E7B01DDBD2D5" codebase="RawDataPrinter.CAB#version=2,0,0,0">
</object>
Where do I put that "RawDataPrinter.CAB" file on my server?
From the server standpoint, the CAB files are just data files. They're not executed on the server - they're installed and executed on the client, that's the whole point. So place them anywere you want. For example, create a subfolder called "cab" under the root of your website and place them there.
If ActiveX (AKA "objects") is disabled in IE, then you have to duplicate the desired functionality in ASP. Depending on the nature of the project, it may or may not be possible.

ASP .Net MVC - Images not being shown in published build

I am developing an ASP .Net MVC application and on my dev machine, the application runs as expected and, more importantly, the images mentioned in the CSS file are displaying correctly too.
However, when I publish this application to a testing server, the web app runs fine, but the images are not shown.
If I modify the URL in IE when testing the output from the test server, the image is returned, meaning that the file is there but it just won't appear within the view page when using the site normally.
I have tried alternative servers too, but the result is the same.
To confirm, here's a line from the CSS page referencing the image...
background-image: url('/Content/Images/Logo/myLogo.jpg');
Any suggestions?
Cheers
Brett
The URLs are not correct, likely due to the fact that you are publishing in a subfolder and so they are no longer at the root of the server. I usually use Url.Content( "~/Content/Images/..." ) to build the url instead of hard-coding it. That way it will take into account the routes when building the path.
Example:
<img src='<%= Url.Content( "~/Content/Images/banner.jpg" ) %>' alt="Banner" />
I had the same issue, but I found the reason why it was forcing authentication on the Contents folder.
When a user is not logged in yet, they are classified as Anonymous Authentication. In IIS7 (which is what I am using, guessing it is the same in IIS6) you need to open the authentication window in features view. Then edit the Anonymous Authentication, to use your application pool identity, or the default one, just make sure that user has permissions to read in that folder.
That fixed it for me, hope it works for you.
Possible relative paths are wrong...Possible that they are wrong for CSS file itself. You can use FireBug to see if CSS loaded correctly, then you can examine image request, often in such situations you will see red(error) items. This could help to localize problem.

Resources