tinymce mcImageManager Configuration - asp.net-mvc

We have configured NFS (Network File Share) and created a Virtual Directory Link to NFS in the ASP.NET MVC Website. <br>
Here is the configuration.
\172.0.0.1\Webs\Images is Network File Share (from UNIX)
"https://www.testsite.com/Images" - Virtual Directory Link to NFS
When we try to Insert an Image from tinymce editor, the MCImageManager does not show any images and it says "File/Folder was not found". Are there any other settings/permissions we are missing?
Another question,
Can we use MCImageManager on load balanced configuration? Our ASP.NET MVC site is load balanced and configured to use SQL Session State. Does it create any problem ?
Thanks in advance for your help.

This answer is probably too late for you, but since I just went through a slightly different exercise - I am using a folder outside of the website root, not a NFS.
So if you are storing images in a folder configured like this:
<!-- General file system options -->
...
<add key="filesystem.rootpath" value="C:/temp/Upload" />
...
and you configure the preview section like this:
<!-- Preview options -->
...
<add key="preview.wwwroot" value="C:/temp/Upload" />
<add key="preview.urlprefix" value="{proto}://{host}/ExternalImage/" />
...
And an image like this C:/temp/Upload/anawesomepic.jpg is going to be served at {proto}://{host}/ExternalImage/anawesomepic.jpg
TinyMCE then uses preview URL when inserting the image in edited document.
If you look at ImageManager source code in ImageManagerPlugin.cs you will see that at one point in OnCustomInfo method it calls this line:
info["thumbnail_url"] = man.ConvertPathToURI(thumbFile.AbsolutePath);
ConvertPathToURI is where the plugin removes the prefix defined in preview.wwwroot config item. Then ImageManager prepends that with preview.urlprefix, probably somewhere in javascript.
In my case I have an HttpHandler that handles images in ExternalImage, so the setup is definitely not quite like yours but maybe it helps.

Related

ASP MVC site-wide META tag customization

I'm developing a simple CMS using ASP MVC and I have plan to deploy the CMS to a few domains with different title, meta tag and a few site-wide configuration. I'm using ASP MVC and believe Razor can help inject the custom meta tag before serving the page.
My question is - should I save the configuration in web.config? or I should just save in in a static site-wide variable? then pass them to the view and spit it using razor when my page is serve?
Web.config? or a static variable is better?
I belive it's not really metter use Web.Config or static variable unless you have really high load site. Becouse Web.Config get's cached once application starts and if it changes IIS track the changes and load it again in memory. Static valiable, in general, is in memory too.
I recommend use Web.Config, but only becouse of opportunity make changes to your meta tags and not rebuild solution.
You can use your domain name for access to a partial view from _Layout.cshtml:
F.e.
<html>
<head>
#Html.Partial(Request.Uri.Host);
. . .
</head>
For domain names domain1.tld and domain2.tld you must create shared views domain1.tld.cshtml and domain2.tld.cshtml with similar content:
<title>domain 1 title<title>
<meta name="description" content="domain 1 descritpion" />

Should MVC Bundling allow multiple CDN paths to be included for each file in the bundle?

I would like to bundle 2 css files related to Twitter Bootstraps.
"~/Content/Themes/Base/CSS/bootstrap-theme.css"
"~/Content/Themes/Base/CSS/bootstrap.css"
Each of the file has a separate URL to its CDN:
//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css
//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css
How can I provide 2 CDN paths to 2 separate css files in the same StyleBundle?
Do I need to create 2 StyleBundles separately, each includes a single css file? This seems to be counter productive for the effort of bundling.
Any help will be appreciated. Thanks.
You will bundle as follow:
bundles.Add(new StyleBundle("~/Content/bootstrapTheme", "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css").Include(
"~/Content/Themes/Base/CSS/bootstrap-theme.css"));
bundles.Add(new StyleBundle("~/Content/bootstrap", "http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css").Include(
"~/Content/Themes/Base/CSS/bootstrap.css"));
Its not counterproductive because you need to understand why MVC allows you to bundle CDN Paths:
When bundling with the CDN, the CDN tag will be referenced in production, and the local version will be referenced when debugging.
In your webconfig you can set which one gets rendered:
Set <compilation debug="true"/> to use the local file, and <compilation debug="false"/> to use your CDN.
To call this in your view: (Note: what you put between the () here must be the same as the first parameter above in the StyleBundle.
#Styles.Render("~/Content/bootstrapTheme")
#Styles.Render("~/Content/bootstrap")
Add it as shown below:
url("http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600");

Cannot import the CSS in JSF pages

I'm learning to use ADF on Oracle jDeveloper 11g.
I created an ADF Fusion Web Application (with the WebLogic webserver) and I created a JSF page under \ViewController\public_html. Then I created a CSS skin file (for JSF) and I put it under \ViewController\WebContent\resources\css\
I want to apply such style rules to the JSF page. To do this I put it into such page the line
<h:outputStylesheet library="css" name="prova.css" id="CASD"/>
where prova.css is the name of the CSS file I've created.
It doesn't work, neither using /css instead of css or /resources/css, etc.
Try using <af:resource type="css" source="your source path here" /> instead.
You shoud make a skin and add your page. When you make a skin
the name of skin is set in trinidad-config.xml in your project:
<skin-family>skin2(name of skin)</skin-family>

Asp MVC 3: Dynamically resolve relative resources in views

I have a javascript application that runs in a view (index.cshtml).
Problem:
The problem is all relative paths are relative to the current url, which would be ok in a simple html webapp but not in asp mvc. The js-app shouldn't have to bother whether it's served in a normal html file or via a asp mvc page.
I.e. http://www.domain.com/<controller>/<action>/ contains a script test.js. This script loads an external xml file searching relative to it ie. "data/data.xml". The resulting url reads http://www.domain.com/<controller>/<action>/data/data.xml. This isn't found.
Question:
Is there a way to route static files (images,..., maybe even js files) to the content folder like "~/Content/controller/action/<pathToFile>/"?
Any help appreciated!
Lg
warappa
PS: I know about Url.Content() but that doesn't fit here.
The solution doesn't require mapping - just a simple html tag in the header:
<base href="#(Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped) +
Url.Content("~/content/controller/action/"))" />
Lg
warappa
EDIT
Some browsers need an absolute url - sample updated.
In you can use absolute URL addresses to access you static resources:
$('img').attr('src', '/Content/Pictures/picture1.png');
or
<script src="/Scripts/script.js"></script>
This way you will allways get the same resources relative to the page base address, no matter if you load the script in a /{Controller}/{Action}/{View}, {Area}/{Controller}/{Action}/{View}, a custom route or even in a static script html page.
Or perhaps what you're looking for is the use of css files, since CSS's url('<path>') resolves the addresses relative to the CSS file's location. You would just need to import the one CSS file that had all the resource (image?) file paths. Then the scripts could reference the distinct class names, thus not being location aware at all. This is what libraries like jQuery UI do. But again this would require a fixed folder structure relative to the CSS document.

Where do you store images for asp.net mvc projects and how do you reference them from site.master

I have a new asp.net mvc project and i am trying to figure out the best place to store images and also how i would reference them from site.master (in cases where i have a header images that i want to show up on all pages).
Suggestions or best practices?
What I generally do is create an "Images" folder inside my Content folder. Where you place your images is really up to you, as long as you are consistent.
Referencing these images from your Site.Master is the same as if you referenced it from any view:
<img src="/Content/Images/mylogo.png" />
<img src="#Url.Content("~/Content/Images/logo.png")" />
Using this in a Razor view on MVC 5. Images are stored in /Content/Images.
<%=Html.Image("~/Content/Images/xxx.png")%>
This resolves from wherever you are in the site hierarchy. Html.Image is a part of the the Microsoft.Web.Mvc futures assembly.
or in mvc2:
<img src="<%: Url.Content("~/Images2/landingMain/safety.png") %>" alt="safety" />
U must put all your images in Content Folder like :-
Content-->Images-->.IMG files and
same as style sheet files
Content Folder like Content-->.css hence it easily load the images and css otherwise it is not executed in proper manner.

Resources