Kentico Library media file not available in MVC website - asp.net-mvc

I'm creating a Kentico media library file using Kentico API 11.0.26. The CMS and MVC app are on a web farm. Both are in healthy state.
The file gets created fine, but is only accessible on the CMS application, not on the MVC website. This is true for both Direct Path link as well we Permanent link.
Copying/pasting the Permanent link in browser preceded with MVC domain gives this message: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
Can someone explain what "same UNC root defined " means in this section:
If you are running the system on a web farm and have the same
UNC root defined on all servers, it is necessary to add the
following key into your web.config file. The files stored in the
libraries are then not transferred when synchronizing the web farm
content:
<add key="CMSWebFarmSynchronizeMediaFiles" value="false"/>
https://docs.kentico.com/k12/configuring-kentico/configuring-the-environment-for-content-editors/configuring-media-libraries

The UNC (Universal naming convention) is the standard for identifying a server/machine on a network, used like so: \\server-name\rest of path
In Kentico, you would be using UNC to tell Kentico where you're storing media library files if it's on a different server in the network.
The first thing that came to mind why you're getting a 404 is it's probably that the media URL has a tilde (~) preceding it. If that's the case, remove that tilde and see if the problem is resolved. Personally, I do a replace like so:
MediaLibraryHelper.GetPermanentUrl(mediaLibraryFile).Replace("~/", "/")
I'm not aware if there's a helper function to give you a URL without string replacing the tilde.

Related

URL Routes In IIS7 MVC 5 (Single Paged Application)

After publishing a MVC5 web application of mine to my IIS server (Individual User Accounts), it would seem that the URL is accessed incorrectly.
During debug, it would be e.g http://localhost:1234/api/Account/UserInfo?=XXXXX
The debug works just fine. The only issue kicks in after I've published it via my IIS7 server.
After publishing and using Google Chrome's console, it would appear that the page is requesting for a resource at mydomainname.com/api/Account/UserInfo?=XXXX instead of mydomainname.com/WEBAPPLICATIONNAME/api/Account/UserInfo?=XXXX.
My best guess is to modify the URLs in /Scripts/app/app.datamodel.js but it would just cause more parsing problems.
I've searched around and can't seem to find any related problems. I hope someone here will be able to lend a hand.
Look like you are using relative path like "/api/Account/UserInfo". Instead i'll recommend you to use #Url.Content("/api/Account/UserInfo"). This will solve your problem
Explanation
In local system when we run application in WebDev server it never have sub folder (like WEBAPPLICATIONNAME) therefore you relative path work correctly. but when you host your application in IIS under Default website in another new website /Virtual folder (like 'WEBAPPLICATIONNAME') then "/api/Account/UserInfo" fall back to Default Website because for '/' in starting. #Url.Content or #Url.Action make sure to add virtual directory name, hence changing your path to "/WEBAPPLICATIONNAME/api/Account/UserInfo" in IIS.

ASP.NET MVC server path is different from application path

I have an unusual circumstance where our web server inserts a folder into the url path before loading the page. Let me give you an example:
The app is called equipment and if I were to run it on a normal server setup, it would look like:
www.site.com\equipment\home\index
BUT when I run it on our server, it inserts "idn" in the url:
www.site.com\idn\equipment\home\index
The messes up my relative references. The MVC functions want to redirect to use "\equipment\" instead of "\idn\equipment\". This happens with Scripts.Render(), Return View(), etc.
Also, I can't hardcode the "idn" into my urls b/c then it is no longer relative and it won't work on my dev box or test servers b/c they don't have a "idn" subfolder in localhost.
I also tried functions such as Request.ApplicationPath and what not but none of them return the "idn" in the result.
Is there way to MVC to know that this "idn" was inserted into the url and account for it?
Thanks!
Create your application on the test/production server in the idn folder, then it all works.

IIS isn't serving javascript and css requests on azure webrole application

need your help with this one, i'm running azure deployment on my localhost and get the webpage without css and javascript, when i look in fiddler i see 500 status and the following error: "It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS" on each request for javascript or css file, i already enabled static content on windows feature and it didn't help, i'm using iis 7.5 on windows professional 64 bit with azure sdk 1.7, tried anything, and nothing helped, can't change the site to web application cause the website only exist on iis while i'm running debug, any idea what to do?
Could it be that the directory from which you're serving JS/CSS files contains a web.config file? If this is the case this will be causing the problem.
Your web.config contains an element which can only be defined in a real web application (in the root of your application for example- or in the machine.config. To fix this issue you'll need to open the machine.config (C:\Windows\Microsoft.Net\Framework\v4.0.30319\Config\machine.config) and look at each configSection defined here that is also included in your web.config (in the folder containing the JS/CSS files).
If the configSection in the machine.config contains the allowDefinition attribute with MachineToApplication as value this means you cannot use that configSection in a web.config that isn't located in a web application. Meaning in your case you'll need to remove that configSection from the web.config in the folder containing the JS/CSS files.
If you're using ASP.NET MVC this is probably your Content folder.

Silverlight Cannot find XML data source

I am very new to Silverlight development. I understand that this is client side technology therefore the paradyme is differant from that of conventional ASP.NET development. Having said that, I don't understand where my server side code is deployed.
I have a silver light \ MVC application. I am trying to read an XML document from within my 'Models' folder. The following peice of code is executed from within a class that is in the same location as the XML document, 'Models'. The load() results in a SystemIOFileNotFound exception. I noticed that when building the application the XML document is not laid down in the same location as the web project's assembly. I assume this is specific to the fact that this is a Silverlight project. Can someone tell me what I'm missing?
_xdoc = new XDocument();
_xdoc = XDocument.Load(new Uri("videos.xml",UriKind.Relative).ToString());
Edit..
The behavior I am after is the start page (silverlight) populates controls via a server side controller. ie localhost/video
Silverlight can't access your filesystem (thankfully), which is why you can't access the file. Try embedding it as a resource, or storing it in the local storage API provided by silverlight.
Assuming that your Models folder is in the Web project (i.e. not the Silverlight project), I think that your problem is unrelated to Silverlight.
The code loading the XML file assumes that the file is in the current directory, so you need to ensure this through your deployment technique.
If you are doing this in the Silverlight part, you should put the XML file in an embedded resource and access it as a stream (get it with Assembly.GetManifestResourceStream) or as a resource (a la WPF, not an embedded resource) and access it with the package part syntax.
The problem was that I was attempting to access this static resource as you would in typical ASP.net. However I found it necessary to map the path to the file using the current HTTPContext:
HttpContext.Current.Server.MapPath("~/App_Data/videos.xml");
So the above worked for me. Since this code is in the web project and not in the silverlight project I am still unclear as to why I cannot just access this resource using a relative path. This code will be executed in the context of the web server.
i.e.
XDocument.load(../App_Data/videos.xml);

ASP.NET MVC and IIS 5

What is the best way to get hosting of an ASP.NET MVC application to work on IIS 5 (6 or 7). When I tried to publish my ASP.NET MVC application, all I seemed to get is 404 errors. I've done a bit of googleing and have found a couple of solutions, but neither seem super elegant, and I worry if they will be unusable once I come to use a shared hosting environment for the application.
Solution 1
Right-click your application virtual directory on inetmgr.exe.
Properties->Virtual Directory Tab-> Configuration.
Add a new mapping extension. The extension should be .*, which will be
mapped to the Executable
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,
or the appropriate location on your
computer (you can simply copy this
from the mapping for .aspx files). On
the mapping uncheck "check that file
exists".
3 X OK and you're good to go.
If you want, you can apply this setting to all your web sites. In
step1, click on the "Default Web Site"
node instead of your own virtual
directory, and in step 2 go to the
"Home Directory" tab. The rest is the
same.
It seems a tad hacky to route everything through ASP.NET.
Solutions 2
Edit the MVC routing to contain .mvc in the URL and then follow the steps in solution 1 based around this extension. Edit: The original image link was lost, but here it is from Google's Cache:
Answer is here
If *.mvc extension is not registered
to the hosting , it will give 404
exception. The working way of hosting
MVC apps in that case is to modify
global.asax routing caluse in the
following way.
routes.Add(new
Route("{controller}.mvc.aspx/{action}",
new MvcRouteHandler()) {
Defaults = new RouteValueDictionary (new{ controller
= "YourController"} ) });
In this way all your controller
request will end up in *.mvc.aspx,
which is recognized by your hosting.
And as the MVC dlls are copied into
your local bin , no special setttings
need to be done for it.
I think either way you'll have to do Solution 1.
Consider the HTTP Request pipeline.
A request comes into IIS.
IIS checks port/host header to see if it has a web site set up to capture requests for that host header/port.
IIS investigates the file extension of the request (.php, .asp, .aspx) and hands it off to an ISAPI that can handle that type of request.
Only at this point does ASP.NET (or a PHP runtime) kick in. If IIS does't have that mapping then it'll never hand off the request to the ASP.NET runtime and the request will never reach your code. That's why you need that glob (*) mapping to the ASP.NET ISAPI.
ASP.NET MVC framework urls often end with no file extension at all. If you want these requests to get handled by ASP.NET (or some other runtime) you have to map all requests regardless of the file extension to that ISAPI (ie. aspnet_isapi.dll).
This is often also done for HttpHandlers that need to serve off media like .jpg, .gif. For the handler to be hit it needs to get mapped to your code even though .jpg isn't a "normal" ASP.NET file extension.
HTH,
Tyler
Run:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll -i
This will reset IIS registry settings for aspnet user.
Create the virtual directory:
1. Right click on the directory you want to convert
select Properties
under Directory, select Create.
under Configuration, select Add.
for Executable insert:
C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll
for Extension insert: .*
uncheck “Check that file exists”
under Documents add entry point file, ie: Default.htm, index.htm, Global.asax
under Directory Settings
select Edit...
select Anonymous access
uncheck Allow IIS to control password
uncheck Basic authentication
uncheck Integrated Windows authentication
under ASP.NET, make sure version = v4.0.30319
TAKE NOTE of User Name ie: IUSR_AVSJ82S
Set sharing permission of physical directory:
In windows explorer, go to the physical directory that was converted to a virtual directory.
Right click the directory name
select properties
under security tab, select Add
enter the IIS User name ie: IUSR_AVSJ82S click check name.
click OK
set permissions to Read and Write.
FYI:On server 2003 (developing an app that had to connect to the RPS), it didnt' allow me to add the extension .*, I used the alternate solution modifying the route clause, and that
worked.
Have you tried adding .aspx to the end of the controller name?
It worked for Stack Overflow question Where can I get ASP.NET MVC hosting?.

Resources