Flex modulleader url, why cant it just look at the root? - apache-flex

We are using pureMVC multicore as the flex Framework,
When we need to load a module we use the first line "moduleEval.swf";.
It works well in local for testing.
But not on the production server which is obvioulsy online, in which case i need to put he full URL.
Is that normal ?
moduleLoader.url = "moduleEval.swf";
//moduleLoader.url = "http://www.foobar.com/site_media/mymodule.swf";
Thanks,
Greg

I almost always use absolute urls, without the site name. The URL base directory is wherever your root application is. So if you load a module within another app, and that module loads another or something, any relative urls are relative to the base app.
moduleLoader.url = "/site_media/moduleEval.swf";

Related

How do I get the ASP.NET content relative path

Doing a project between multiple people, and a few components (web app, services app and some others). We will be storing some information inside the Content folder of the web app so it can be accessed directly from the web server with an href, however other components outside of the web app need to access this folder as well, and since we are sharing the project between multiple people using an absolute path is not an option. What options do we have?
EDIT: Trying to explain it a little better.
What i have exactly is, a web project, a "data project" which is just a dll, a "logic" project which is another dll and a services project which is an exe/service.
Both the web project and service project consumes the methods from the logic, and the logic from the data project. Being the last one the responsable for storing data (in a database) and also in the file system.
This "filesystem" path should be configurable, and we are aiming to put it into the content folder of the web project so multimedia files can be accessed directly rather than doing a byte stream.
Now in the web.config(config file of the web app), and app.config(config file of the services app) i could set the absolute path to web/content (the same for both config files) and the data dll would use it without problems. Now the main problem is that we cannot put an absolute path in the config file because each person works on a different computer with obviously different file paths. So if i could just write something like: ~/project/Web/Content rather than C:/myfolder/stuff/blabla/project/web/content in the config files, with ~ resolving the path to the project, this is what i want! Or maybe better ideas about how to share a folder with these apps without adding absolute paths hardcoded somewhere.
What you want to use is:
Server.MapPath("/Content/filepath.ext");
This will give you the absolute path of a file based on it's position within the website, in this case, from the /Content directory.
For a program external to the website, you have a couple options;
The easiest to implement might be a simple configuration value in the external program which points to the directory. My guess is you've already decided that's not ideal, but it may be the quickest way.
Alternatively, there's a Microsoft .NET assembly which gives you easy access to IIS information (I can't recall its name off the top of my head!). You could use this assembly to find the appropriate website, and retrieve its root directory. I'll see if I can find it and get an example, or maybe someone else will see this and post an answer with that information.
Please check the following method "ResolveClientUrl"
MSDN
Use the ResolveClientUrl method to return a URL string suitable for use by the client to access resources on the Web server, such as image files, links to additional pages, and so on.
http://msdn.microsoft.com/en-us/library/system.web.ui.control.resolveclienturl.aspx

multiversioned sub application asset paths in flex 4

Hopefully someone can help here, more or less looking for a) solution to relative paths or b) insight on another method of loading assets.
We have a standalone web application that is using SDK 4.1 and looks in its relative assets folder for all images and external swfs to be loaded.
on the server, this is the absolute path of the assets directory:
/ApplicationRoot/versionFldr/controls/assets/*
the application uses relative paths in all cases of loading an asset.. and this is continously being added to and updated as we advance versions of the app.
So, in essence, the app is looking for:
assets/*
now forward to the NEW application, lets call it "ParentApp" and the above application "ChildApp".
Parent App is in a different server directory than ChildApp
/ParentApp/version/controls/ParentApp.swf
/ChildApp/version/controls/ChildApp.swf
now, when ChildApp loads into ParentApp, it assumes that it is in the same directory that it's always been in. So, it looks for assets/* and cant find them because
/ParentApp/version/controls/assets/* != /ChildApp/version/controls/assets/*
I need to find a solution to have ChildApp look in an absolute path for ALL loaded assets when it is a child of ParentApp and have it look in paths relative to itself when it is standalone.
The caveats I have are that images are loaded into various controls, caches, and even mx:Text fields (html text with tags). I'm trying to avoid having to globally replace all path links across the application and having to create new coding procedures when new assets are created for the app. ChildApp is in production and has to stay on the 4.1 SDK.
ParentApp is new and has much more flexibility.
I've tried -source-path and -library-path compiler options in childApp, but this lead to compile errors and I have not been able to proceed.
Thank you in advance for any insight and help!
-AJ
I would solve this by having a "baseURL" variable in the child app. Give it a default value so that you can form the usual relative URL's that you are using: `var baseURL:String = "/assets/";
Unfortunately, you then have to modify every asset path in the child app so the path to the assets is something like: baseURL + assetFileName
When the child app is loaded into the parent app, you then give this baseURL variable a non-relative path. Ideally, you do that early in the process, before the child app tries to load any assets.

Problems with mediaElement.Source and absolute path

I have a SL project that is simply the MediaElement. I embed this in my aspx page and do all the controling of the element from the aspx page throught the java to managed code bridge. I had all my video files in the project as resources for testing but now want to move them out to the server where they will live. The server is in a different domain from my development box but I have access. I can see my files by going to the "run" command and typing that path as follows: "\mediaserver.otherdomain.com\Content\MyVideo.wmv" I can access the folder and view the video's fine from my computer. However, when I do my
`mediaElement.Source = new Uri(MediaPath, UriKind.RelativeOrAbsolute);`
in my code to load the video into Silverlight video does not play. The Media path is "\MediaServer.OtherDomain.com\Content\MyVideo.wmv. I have image files that I reference using the same path "\MediaServer.OtherDomain.com\Content\MyVideo.jpg" and they display fine.
When I debug and look at the values set in the .Source propery I see:
Absolute Path = "/Content/MyVideo.wmv"
Absolute Uri = "file://MediaServer.domain.com/Content/MyVideo.wmv"
Host = "MediaServer.domain.com"
This all looks good, so why don't I see the video?
Silverlight does not allow you to use cross domain references out of the box. You need to add an exception to do so.
If you're using SL4, look at Making a Service Call Across Domain Boundaries

Getting ASP.NET root path to Flex?

I am working on a project that is primarily ASP.NET based. The main project is meant to be deployed to multiple locations for different clients, so one client might be located at website.com/client1 and another at website.com/client2. Within the application, we regularly use the application root operator ~ to get the path to a resource.
We also have a bunch of Flex applications that get deployed in there, and many rely on web services within the ASP.NET application. What I'm after is a way to reference the services relative to the application root. Here's an example of the location of some files for two client deployments:
Client A
website.com/clientA/swf/FlexApplication.swf
website.com/clientA/services/webService.asmx
Client B
website.com/clientB/swf/FlexApplication.swf
website.com/clientB/services/webService.asmx
FlexApplication and webService are both exactly the same, so what I want to do is something like this in the Flex code:
var myService:CustomService = new CustomService(~/services/webService.asmx);
myService.callMethod("Test");
I would like to avoid using relative paths for the usual reasons. Is there a good way to do this or a good way to pass the root url to the flex application from ASP.NET? Thanks in advance.
Its definitely a good idea to avoid relative URL's. The easiest way is to pass the information in via Flash Vars in the HTML embed statement.
Check out Adobe's documentation on using FlashVars with Flex: http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html
Summary:
Add a line to the HTML embed statement like this:
<param name='flashVars' value='serviceRoot=/myserviceRoot'/>
Then access it in Flex via the mx.core.Application.application.parameters accessor
import mx.core.Application;
var parameters:Object = Application.application.parameters;
var serviceRoot:String = parameters['serviceRoot'];
relative to the application root
Flex knows nothing about the application root of a ASP.NET application. The only thing that the Flex app knows is the URL that it is served from. It does not know the URL of the page. Keep in mind that the URL of the page and the URL of the SWF are not the same.
It appears, given your directory structure, that you can use the SWF's URL to get the information you're after.
In a Flex 3 Application, you can get use the url property of the Application tag:
(Application.application as Application).url
In a Flex 4 Spark application, you can also use the url property of the Application Tag, but you have to get it differently:
(FlexGlobals.topLevelApplication as Application).url
Then you can parse it with URLUtils to get your directory structure. Probably store that as a global variable in your Flex application somehow and use it to construct the URL for the service calls you are making to the remote server.
I use this handy little utility to get URL information via javascript inside the .swf.
http://www.flexpasta.com/index.php/category/utility-classes-that-help-you-deal-with-string-numbers-arrays-and-objects-in-actionscript/

How to MapPath in an IIS7 Rewrite Provider?

I am using the rather excellent IIS7 Rewrite module (V2), and want to create a custom RewriteProvider that rewrites differently depeneding on whether the physical file exists.
I have successfully created a provider, as in this tutorial:
http://learn.iis.net/page.aspx/804/developing-a-custom-rewrite-provider-for-url-rewrite-module/
However, really need to be able to map the url to a physical path - I would normally do this via HttpContext.Current.Server.MapPath() or HostingEnvironment.MapPath(), but it looks like the HttpContext has not been initialised (at least within the current App Domain - since the ReWrite module is native code, I'm having difficulty working out where I can get this information).
I don't really want to have to resort to creating my own rewrite module to get around this problem - anyone have any clues for me?
Thanks!
Mark.
You will not be able to get to it using those APIs since the code runs in a different AppDomain than the one ASP.NET is using.
The only way I can think to make this work is to pass the right Server Variable that includes the physical path to your extension and do a Path.Combine() yourself.
So assuming you have an extension called YourProvider that you are calling somehow like this:
{YourProvder:{URL}}
You can do:
{YourProvder:{APPL_PHYSICAL_PATH}|{URL}}
You can now get the physical path and the URL separated by a pipe | , make sure to pass the Physical Path first since the URL is in the control of external users you do not want them to trick you into getting a different physical path.

Resources