Not able to access images folder inside a module - orchardcms

I have an Images folder inside my module. I have added a web.config to this folder.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers accessPolicy="Script,Read">
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule" preCondition="integratedMode" resourceType="File" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
In the view file, I tried using img src=../Images/background.png, and full path resolves to this,
localhost:4126/OrchardLocal/Contents/Item/Images/background.png.
I tried to use this absolute url for image src, localhost:4126/OrchardLocal/ModuleName/Images/background.png, it still didn't work. I get the 404 error.
How to get this working?
Thanks.

You should never use a relative path from a view, as this won't be resolved server-side but client-side, relative to the current path and not to your view file. You can use #Href("~/Modules/ModuleName/Images/background.png") instead, which will get resolved server-side correctly.

Related

Why doesn't IIS Authorization seem to deny access to User Groups

I've a site hosted on IIS7. The site uses Flask with wfastcgi incase that's relevant. It's not publicly facing so I'm trying to just use Windows Authorization to block user groups that I don't want to be able to access it, so I have my web.config set like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="FlaskHandler" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python34\python.exe|C:\inetpub\wwwroot\mysite\wfastcgi.py" resourceType="Unspecified" />
</handlers>
<security>
<authorization>
<add accessType="Deny" users="?" />
<add accessType="Deny" users="GroupName" />
<add accessType="Allow" users="*" />
</authorization>
</security>
</system.webServer>
</configuration>
This doesn't seem to have any effect; users in the AD Group "GroupName" can still load the site as normal. I've tried it with and without the following <add accessType="Allow" users="*" /> line.
What am I doing wrong here?

Azure: App Service: Deploy Virtual Directory

I have an asp.net core app deployed on azure website and the domain is www.somewebsite.org. My web.config file is under site\wwwroot\web.config. Its contents are
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App1.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">
<environmentVariables>
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
I am trying to deploy another asp.net core app with the virtual path www.somewebsite.org/kiosk and I copied the complete directory under site\wwwroot\kiosk and the web.config file is under site\wwwroot\kiosk\web.config. Its contents are:
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Kiosk.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</location>
</configuration>
On Azure portal, in Application Settings for my site, I have
/ - site\wwwroot
/kiosk - site\wwwroot\kiosk
When I try going to www.somewebsite.org, the app1 site is loaded whis is correct. But, when I go to www.somewebsite.org/kiosk, the kiosk app is not being loaded. The page comes back with a 500 Internal Server Error. How do I fix this error? Is it even possible to host multiple apps from separate multiple virtual paths under one website in azure?
In my sub-application web.config file, I did the following and it started working:
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore_TEMP" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\Kiosk.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
</system.webServer>
</configuration>
Now, both the sites are up.
Thanks for your help.
NH
I reproduce your error, and you just need to add <location path="." inheritInChildApplications="false"> in you web.config file which is under site\wwwroot\web.config.
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\App1.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout">
<environmentVariables>
</environmentVariables>
</aspNetCore>
</system.webServer>
</location>
</configuration>

Running Keystone.js with IISnode

I'm fairly new to both Keystone and IISnode so bear with me. I've succesfully been able to run express projects with IISnode and I can run keystone.js projects with node but merging the two has been difficult. When I run the ETW traces alongside I get a "iisnode scheduled a retry of a named pipe connection to the node.exe process" multiple times before I shut it down. I've tried hooking iisnode directly to the keystone index.js file (see below from the web.config) and also to the keystone.js file at the root of the project.
<handlers>
<add name="iisnode" path="node_modules/keystone/index.js" verb="*" modules="iisnode" />
</handlers>
My hunch is that I need to hook it up to the keystone.js file as you normally do to start up the project but you typically need to add a 'keystone' parameter alongside which I'm not quite sure how I can do this with iisnode. Can anyone help me out?
The web.config handler path should be set to your application's entry point, and not node_modules\keystone\index.js. If you used the keystone Yoeman generator, the entry point is the keystone.js file in the root folder of your app.
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="keystone.js" verb="*" modules="iisnode" />
</handlers>
...
</system.webServer>
</configuration>
I have more detail instruction of how to setup keystone.js at IIS.
http://www.dakehe.info/blog/post/deploy-keystonejs-node-cms-at-iis
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="keystone.js" verb="*" modules="iisnode" />
</handlers>
<defaultDocument enabled="true">
<files>
<add value="keystone.js" />
</files>
</defaultDocument>
<rewrite>
<rules>
<rule name="Catch All">
<match url="/*" />
<conditions>
<add input="{PATH_INFO}" pattern=".+\.js\/debug\/?" negate="true" />
</conditions>
<action type="Rewrite" url="keystone.js" />
</rule>
</rules>
</rewrite>
<directoryBrowse enabled="false" />
<iisnode node_env="production" loggingEnabled="true" debuggingEnabled="true" devErrorsEnabled="true" />
</system.webServer>
</configuration>

Orchard CMS Theme Images Not Showing Up

I'm using the correct helper call to get the URL for an image in my theme:
#Url.Content(Html.ThemePath(WorkContext.CurrentTheme, "/Content/Images/my-image.png")
...and I know the image is there and is readable. Yet it's not showing up when I try to browse to it! Why is this happening?
From the docs (http://docs.orchardproject.net/Documentation/Anatomy-of-a-theme):
To enable files to be served, each of the folders that contains static files such as style sheets, images, or JavaScript code should contain a web.config file that contains the following content:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.web>
<httpHandlers>
<!-- iis6 - for any request in this location,
return via managed static file handler -->
<add path="*" verb="*" type="System.Web.StaticFileHandler" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers accessPolicy="Script,Read">
<!-- iis7 - for any request to a file exists on disk,
return it via native http module.
accessPolicy 'Script' is to allow for a managed 404 page. -->
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule"
preCondition="integratedMode" resourceType="File"
requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>

IIS7, web.config to allow only static file handler in directory /uploads of website

If it's possible which I think so, How do I modify my web.config to make a sub directory static -- files inside will only processed as static file, even if its name is "aspx" or something else?
Thanks.
Add the following to a web.config file in the folder containing the files you wish to be served only as static content:
<configuration>
<system.webServer>
<handlers>
<clear />
<add
name="StaticFile"
path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either"
requireAccess="Read" />
</handlers>
<staticContent>
<mimeMap fileExtension=".*" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>

Resources