Trying to record "Page Loads" for custom CMS.
On page load, I invoke a CFC that saves page and user information. Works on interior pages but not Homepage.
Every "Homepage Click" records a "visit" to the homepage and then immediately records a link from the homepage to 404 Error. This means that the 404 Page is being loaded (in the background?) and firing the CFC. The verification of this is what is saved in the database. I have no idea how this is happening.
I have researched several posts here - trying varied approaches:
I have tried removing all includes - this did not fix it.
I have tried IIS Mappings - removing all rewrites and redirects - (from /index.cfm to /) - and this did not fix it.
Code as follows:`
<cfinvoke
Component="components.Page_Count"
Method="RecordPageView"
PageID="0"
Title="Homepage"
LinkName="/index.cfm"
IPAddress="#cgi.remote_addr#"
ThisUserAgent="#CGI.HTTP_USER_AGENT#"
Returnvariable="PageLinkRecorded"
>
CFC Code:
<cffunction
name="RecordPageView"
access="public"
returntype="any">
<cfargument name="PageID" type="string" required="no">
<cfargument name="Title" type="string" required="no">
<cfargument name="LinkName" type="string" required="no">
<cfargument name="IPAddress" type="string" required="no">
<cfargument name="ThisUserAgent" type="string" required="no">
<cfparam name="var.ESID" default="">
<cfparam name="var.CookieID" default="0">
<cfparam name="var.Referer" default="">
<cfparam name="var.VisitDate" default="#Now()#">
<cfparam name="var.IPAddress" default="#cgi.remote_addr#">
<cfparam name="var.IsThisABot" default="FALSE">
<cfif arguments.Title NEQ "">
<cfset variables.MyCookieName = Application.CompanyName>
<!--- remove ALL Special Characters --->
<cfset variables.MyCookieName = "#REReplace(variables.MyCookieName,"[^0-9A-Za-z ]","","all")#" />
<!--- remove ALL spaces from the string --->
<cfset variables.MyCookieName = ReReplace(variables.MyCookieName, "[[:space:]]","","ALL")>
<cfif isDefined("COOKIE.#variables.MyCookieName#_UUID") AND Evaluate("COOKIE.#variables.MyCookieName#_UUID") NEQ "">
<cfset VAR.CookieID = Evaluate("COOKIE.#variables.MyCookieName#_UUID")>
<cfelse>
<cfset VAR.CookieID = CreateUUID()>
<cfcookie name="#variables.MyCookieName#_UUID" value="#VAR.CookieID#" expires="NEVER" />
</cfif>
<cfif Len(arguments.ThisUserAgent) GT 0>
<cfloop list="bot\b,crawl,\brss,feed,news,blog,reader,syndication,coldfusion,slurp,google,zyborg,emonitor,jeeves,Googlebot,Google,duckduckbot,Baiduspider,YandexBot,exabot,Sogou,facebot,facebookexternalhit,ia_archiver" index="bot" delimiters=",">
<cfif FindNoCase(bot, arguments.ThisUserAgent)>
<cfset VAR.IsThisABot="TRUE" />
<cfelse>
<cfset VAR.IsThisABot="FALSE" />
</cfif>
</cfloop>
<cfelse>
<cfset VAR.IsThisABot="TRUE" />
</cfif>
<cfif IsDefined("SESSION.Auth.ESID")>
<cfset var.ESID = SESSION.Auth.ESID>
</cfif>
<cfif IsDefined("CGI.script_name")>
<cfset var.ThisPage = CGI.script_name>
</cfif>
<cfif IsDefined("CGI.http_referer") AND CGI.http_referer NEQ "">
<cfset var.Referer = CGI.http_referer>
<cfif FindNoCase(".css", CGI.http_referer)>
<cfset VAR.IsThisABot="TRUE">
</cfif>
<cfelse>
<cfset var.Referer = CGI.QUERY_STRING>
</cfif>
<cfif VAR.IsThisABot EQ "FALSE">
<cfquery datasource="#Application.DSN#" username="#Application.username#" password="#Application.password#" result="CountSaved">
INSERT INTO content_track (PageID,PageTitle,LinkName,ESID,CookieID,Referer,IPAddress)
VALUES (
<cfif arguments.PageID NEQ "">
<cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.PageID#">
<cfelse>
0
</cfif>
,
<cfif arguments.Title NEQ "">
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.Title#">
<cfelse>
NULL
</cfif>
,
<cfif arguments.LinkName NEQ "">
<cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.LinkName#">
<cfelse>
NULL
</cfif>
,
<cfif var.ESID NEQ "">
<cfqueryparam cfsqltype="cf_sql_integer" value="#var.ESID#">
<cfelse>
0
</cfif>
,
<cfif var.CookieID NEQ "">
<cfqueryparam cfsqltype="cf_sql_varchar" value="#var.CookieID#">
<cfelse>
0
</cfif>
,
<cfif var.Referer NEQ "">
<cfqueryparam cfsqltype="cf_sql_varchar" value="#var.Referer#">
<cfelse>
NULL
</cfif>
,
<cfif var.IPAddress NEQ "">
<cfqueryparam cfsqltype="cf_sql_varchar" value="#var.IPAddress#">
<cfelse>
NULL
</cfif>
)
</cfquery>
</cfif>
</cfif>
<cfset PageRecorded = VAR>
<cfreturn PageRecorded>
</cffunction>
My IIS Rules
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
<rewrite>
<rules>
<rule name="RedirectWwwToNonWww" stopProcessing="false">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^(www\.)(.*)$" />
</conditions>
<action type="Redirect" url="https://{C:2}{REQUEST_URI}" redirectType="Permanent" />
</rule>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="index.cfm" ignoreCase="true" />
<conditions logicalGrouping="MatchAny">
<add input="{URL}" pattern="^.*\.(cfm|cfc|css|gif|png|jpg|jpeg|js|svg)$" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
<rule name="HTTP to HTTPS redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}" />
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".pl" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
<httpErrors errorMode="DetailedLocalOnly">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" subStatusCode="-1" prefixLanguageFilePath="" path="/Content/404-Error.cfm" responseMode="ExecuteURL" />
</httpErrors>
<staticContent>
<remove fileExtension=".scss" />
<mimeMap fileExtension=".scss" mimeType="text/css" />
</staticContent>
</system.webServer>
</configuration>
Related
I want to make an Add-in that :
Is available when Reading an email
Is available when Writing an email
Is Pinnable when Reading an email
So far I've managed to make a Manifest that can achieve 2 out of 3 requirements but not all 3 in the same time.
1+2 is possible with VersionOverrides V1.0 but NOT V1.1
1+3 is possible with VersionOverrides V1.1 but NOT V1.0
Pinning is only possible in 1.1 but then i loose (2)
Any advice ? - other than creating TWO add-ins ?
My sample Manifest.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:bt="http://schemas.microsoft.com/office/officeappbasictypes/1.0"
xmlns:mailappor="http://schemas.microsoft.com/office/mailappversionoverrides/1.0" xsi:type="MailApp">
<Id>d23964fa-8ebb-4351-a07c-5348c5c88ce4</Id>
<Version>1.0.0.0</Version>
<ProviderName>#Fbsall</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="Git the gist" />
<Description DefaultValue="Allows users to access their GitHub gists." />
<IconUrl DefaultValue="https://localhost:3000/assets/icon-32.png" />
<HighResolutionIconUrl DefaultValue="https://localhost:3000/assets/icon-80.png" />
<SupportUrl DefaultValue="https://localhost:3000/support.html" />
<AppDomains>
<AppDomain>fbsall.com</AppDomain>
</AppDomains>
<Hosts>
<Host Name="Mailbox" />
</Hosts>
<Requirements>
<Sets>
<Set Name="Mailbox" MinVersion="1.1" />
</Sets>
</Requirements>
<FormSettings>
<Form xsi:type="ItemRead">
<DesktopSettings>
<SourceLocation DefaultValue="https://localhost:3000/taskpane.html" />
<RequestedHeight>250</RequestedHeight>
</DesktopSettings>
</Form>
</FormSettings>
<Permissions>ReadWriteItem</Permissions>
<Rule xsi:type="RuleCollection" Mode="Or">
<Rule xsi:type="ItemIs" ItemType="Message" FormType="Read" />
</Rule>
<DisableEntityHighlighting>false</DisableEntityHighlighting>
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides" xsi:type="VersionOverridesV1_0">
<VersionOverrides xmlns="http://schemas.microsoft.com/office/mailappversionoverrides/1.1" xsi:type="VersionOverridesV1_1">
<Requirements>
<bt:Sets DefaultMinVersion="1.3">
<bt:Set Name="Mailbox" />
</bt:Sets>
</Requirements>
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<FunctionFile resid="Commands.Url" />
<!-- Message Compose -->
<ExtensionPoint xsi:type="MessageComposeCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgComposeCmdGroup">
<Label resid="GroupLabel" />
<Control xsi:type="Button" id="msgComposeInsertGist">
<Label resid="TaskpaneButton.Label" />
<Supertip>
<Title resid="TaskpaneButton.Title" />
<Description resid="TaskpaneButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url" />
</Action>
</Control>
<Control xsi:type="Button" id="msgComposeInsertDefaultGist">
<Label resid="FunctionButton.Label" />
<Supertip>
<Title resid="FunctionButton.Title" />
<Description resid="FunctionButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>insertDefaultGist</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<FunctionFile resid="Commands.Url" />
<ExtensionPoint xsi:type="MessageReadCommandSurface">
<OfficeTab id="TabDefault">
<Group id="msgReadCmdGroup">
<Label resid="GroupLabel" />
<Control xsi:type="Button" id="msgComposeInsertGist">
<Label resid="TaskpaneButton.Label" />
<Supertip>
<Title resid="TaskpaneButton.Title" />
<Description resid="TaskpaneButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Action xsi:type="ShowTaskpane">
<SourceLocation resid="Taskpane.Url" />
</Action>
</Control>
<Control xsi:type="Button" id="msgComposeInsertDefaultGist">
<Label resid="FunctionButton.Label" />
<Supertip>
<Title resid="FunctionButton.Title" />
<Description resid="FunctionButton.Tooltip" />
</Supertip>
<Icon>
<bt:Image size="16" resid="Icon.16x16" />
<bt:Image size="32" resid="Icon.32x32" />
<bt:Image size="80" resid="Icon.80x80" />
</Icon>
<Action xsi:type="ExecuteFunction">
<FunctionName>insertDefaultGist</FunctionName>
</Action>
</Control>
</Group>
</OfficeTab>
</ExtensionPoint>
</DesktopFormFactor>
</Host>
</Hosts>
<Resources>
<bt:Images>
<bt:Image id="Icon.16x16" DefaultValue="https://localhost:3000/assets/icon-16.png" />
<bt:Image id="Icon.32x32" DefaultValue="https://localhost:3000/assets/icon-32.png" />
<bt:Image id="Icon.80x80" DefaultValue="https://localhost:3000/assets/icon-80.png" />
</bt:Images>
<bt:Urls>
<bt:Url id="Commands.Url" DefaultValue="https://localhost:3000/commands.html" />
<bt:Url id="Taskpane.Url" DefaultValue="https://localhost:3000/taskpane.html" />
</bt:Urls>
<bt:ShortStrings>
<bt:String id="GroupLabel" DefaultValue="Git the gist" />
<bt:String id="TaskpaneButton.Label" DefaultValue="Insert gist" />
<bt:String id="TaskpaneButton.Title" DefaultValue="Insert gist" />
<bt:String id="FunctionButton.Label" DefaultValue="Insert default gist" />
<bt:String id="FunctionButton.Title" DefaultValue="Insert default gist" />
</bt:ShortStrings>
<bt:LongStrings>
<bt:String id="TaskpaneButton.Tooltip" DefaultValue="Displays a list of your gists and allows you to insert their contents into the current message." />
<bt:String id="FunctionButton.Tooltip" DefaultValue="Inserts the content of the gist you mark as default into the current message." />
</bt:LongStrings>
</Resources>
</VersionOverrides>
</VersionOverrides>
I found the answer by looking through a manifest that does exactly what i want.
I had misunderstood how Hosts, Formfactor and ExtensionPoints are declared.
The correct way is something like this:
<Hosts>
<Host xsi:type="MailHost">
<DesktopFormFactor>
<ExtensionPoint xsi:type="MessageComposeCommandSurface"></ExtensionPoint>
<ExtensionPoint xsi:type="MessageReadCommandSurface"></ExtensionPoint>
</DesktopFormFactor>
<MobileFormFactor>
<ExtensionPoint xsi:type="MessageComposeCommandSurface"></ExtensionPoint>
<ExtensionPoint xsi:type="MessageReadCommandSurface"></ExtensionPoint>
</MobileFormFactor>
</Host>
</Hosts>
All content in VersionOverride 1.0 is copied into 1.1.
SupportsPinning is available in 1.1 and works for both Compose and Read.
I have developed a full-stack application with Vue 2, Node , Express and Postgres.
I could deploy the application to Azure , and the system coming up, but when I try to do register user with Register page that I have created , I get " POST … 500 (Internal Server Error) ", **as I have tried with Postman , there is no issue in saving user data with same post controller ** .
Notice that I have set BaseURL to ‘’ in Api.js ( Client ):
import axios from ‘axios’
import store from ‘#/store/store’
export default () => {
return axios.create({
baseURL: ‘’,
headers: {
Authorization: Bearer ${store.state.token}
}
})
}
this is Register controller in /Controller folder :
//Registering user
async register(req, res) {
const hash = bcrypt.hashSync(req.body.password, 10);
try {
const user = await User.create(
Object.assign(req.body, { password: hash })
);
const userJson = user.toJSON();
res.send({
user: userJson,
token: jwtSignUser(userJson),
});
} catch (err) {
res.status(500).send({
error: There is error in registering: ${err},
});
}
},
I have added the following web.config file in dist folder, but it doesn't resolve the issue :
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension="woff" mimeType="application/font-woff" />
<mimeMap fileExtension="woff2" mimeType="application/font-woff" />
</staticContent>
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
</rules>
</rewrite>
<httpErrors>
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="500" subStatusCode="-1" />
<error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />
<error statusCode="500" path="/survey/error" responseMode="ExecuteURL" />
</httpErrors>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Could you please let me know how I could resolve the issue .
I have this include at the top of all of my ASP pages, to redirect to https for all pages NOT in folders called "words" and "generators". I don't want them on ssl as I heard moving to SSL can have a big impact on AdSense income.
I also redirect so that if a user ends up on an SSL version of pages in the words and generators folders, it takes them to the non ssl page.
And finally I have one that redirects from the www version of a page to the non www version, e.g. www.test.co.uk to test.co.uk
My code is below.
I wondered if I am doing this in a very resource intensive way and if there is a better way to do it using web config or something like that, or is it a case of if it isn't broken, don't fix it?
I realise my code is very basic and clunky, sorry.
SERVER_NAME = lcase(Request.ServerVariables("SERVER_NAME"))
SCRIPT_NAME = lcase(Request.ServerVariables("SCRIPT_NAME"))
QUERY_STRING = lcase(Request.ServerVariables("QUERY_STRING"))
SECURE_MODE = lcase(Request.ServerVariables("SERVER_PORT_SECURE"))
str0 = request.servervariables("url")
arrFolderData = Split(str0, "/")
strLastFolder = arrFolderData(UBound(arrFolderData)-1)
words_str = instr(strLastFolder,"words")
gens_str = instr(strLastFolder,"generators")
'' if page = http, and page is not in "words" or "generators" folder then redirect to https version of page
if SECURE_MODE = 0 AND words_str = 0 AND gens_str = 0 then
SERVER_NAME = replace(SERVER_NAME, "www.", "")
go_to_url = ""
go_to_url = go_to_url & "https://"
go_to_url = go_to_url & SERVER_NAME
go_to_url = go_to_url & SCRIPT_NAME
if QUERY_STRING <> "" then
go_to_url = go_to_url & "?" & QUERY_STRING
end if
Response.Buffer = true
Response.Status = "301 Redirect"
Response.AddHeader "Location", lcase(go_to_url)
Response.End
end if
'' if page = https, and page is in "words" or "generators" folder then redirect to http version of page
if SECURE_MODE = 1 AND (words_str = 1 OR gens_str = 1) then
SERVER_NAME = replace(SERVER_NAME, "www.", "")
go_to_url = ""
go_to_url = go_to_url & "http://"
go_to_url = go_to_url & SERVER_NAME
go_to_url = go_to_url & SCRIPT_NAME
if QUERY_STRING <> "" then
go_to_url = go_to_url & "?" & QUERY_STRING
end if
Response.Buffer = true
Response.Status = "301 Redirect"
Response.AddHeader "Location", lcase(go_to_url)
Response.End
end if
'' redirect to non "www" version of page
if left(SERVER_NAME,3) = "www" then
SERVER_NAME = replace(SERVER_NAME, "www.", "")
go_to_url = ""
go_to_url = go_to_url & "http://"
go_to_url = go_to_url & SERVER_NAME
go_to_url = go_to_url & SCRIPT_NAME
if QUERY_STRING <> "" then
go_to_url = go_to_url & "?" & QUERY_STRING
end if
Response.Buffer = true
Response.Status = "301 Redirect"
Response.AddHeader "Location", lcase(go_to_url)
Response.End
end if
Thanks to the help from #Carlos Aguilar Mares I was able to replace the code above with:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Canonical HostName" stopProcessing="true">
<!-- Redirect to the non-www host -->
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.(.*)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="NON HTTPS" enabled="true" stopProcessing="true">
<!-- Redirect to HTTPS as long as pages are not in words, generators or v folders -->
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{REQUEST_URI}" pattern="^/words/[a-z 0-9]*" negate="true" />
<add input="{REQUEST_URI}" pattern="^/generators/[a-z 0-9]*" negate="true" />
<add input="{REQUEST_URI}" pattern="^/v/[a-z 0-9]*" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Yes, that could be easily done and likely much faster (no longer in script, no longer parsing the code, regex and logic in native code, plus more maintainable, etc) if using URL Rewrite and configuring that in your web.config.
The rules would look something like the following:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="NON HTTPS" enabled="true" stopProcessing="true">
<!-- Redirect to HTTPS as long as it does not end in words/generators -->
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{URL}" pattern="(words|generators)$" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="HTTPS" enabled="true" stopProcessing="true">
<!-- Redirect to HTTPS as long as it ends in words/generators -->
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="on" />
<add input="{URL}" pattern="(words|generators)$" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="Canonical HostName" stopProcessing="true">
<!-- Redirect to the non-www host -->
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www\.(.*)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I have a ColdFusion website that programmatically handles "forbidden"/"unauthorized" requests in onrequeststart() in Application.cfc based on the logged in user's attributes. For example (FYI: SESSION.User is initialized in onSessionStart():
<cffunction name="onRequestStart" returnType="Boolean" output="false">
<cfargument name="targetPage" type="string" required="true">
<cfparam name="REQUEST.MinSecurityLevel" default="0" />
<cfparam name="REQUEST.IsLoginRequired" default="false" />
<cfif REQUEST.IsLoginRequired AND NOT SESSION.User.isLoggedIn()>
<cfscript>
SESSION.LoginMessage =
"Your session has timed out. Please log in again.";
SESSION.LastPageVisited =
getPageContext().getRequest().getRequestURI();
if (Len(Trim(getPageContext().getRequest().getQueryString())))
SESSION.LastPageVisited =
SESSION.LastPageVisited
& "?"
& getPageContext().getRequest().getQueryString();
</cfscript>
<cflocation url="/user/login/" addtoken="false" />
<cfelseif SESSION.User.getSecurityLevel() LT REQUEST.MinSecurityLevel>
<cfheader statuscode="403" statustext="Forbidden" />
</cfif>
<cfreturn true />
</cffunction>
In IIS (version 7), I have an error page setting with Type "Execute URL" and my custom 403 page path.
I am able to trigger this, and it properly displays my custom 403 page, but it returns a HTTP Response Code 200.
Shouldn't this return a 403?
It seems as though I found a solution in my response to #Miguel-F above. I simply mimicked part of what I'm doing to handle 404 errors:
/missing-template/index.cfm:
<cfheader statuscode="404" statustext="Not Found" />
/not-authorized/index.cfm:
<cfheader statuscode="403" statustext="Forbidden" />
I thought that adding a 403 header to the 403 handler page would result in an endless loop, but it works fine.
I also added in onRequestStart() since there's no need for further processing once the 403 is triggered:
<cfelseif SESSION.User.getSecurityLevel() LT REQUEST.MinSecurityLevel>
<cfheader statuscode="403" statustext="Forbidden" />
<cfreturn false />
</cfif>
I have a problem with disabling ribbon button via javascript custom rule.
The action for that I want to add "enable rule" is called Mscrm.AddExistingRecordFromSubGridAssociated -> which is displayed when subgrid gets focus.
I use the ribbon workbench solution and I almost sure I did everything fine, but it doesn't work.
javascript:
utils.ribbon.isAddExistingDisabled = function(grid) {
return false; //just for test I wrote always false, but it's enabled anyway :/
}
CommandDef:
<CommandDefinition Id="Mscrm.AddExistingRecordFromSubGridAssociated">
<EnableRules>
<EnableRule Id="Mscrm.AppendToPrimary" />
<EnableRule Id="Mscrm.EntityFormIsEnabled" />
<EnableRule Id="my.incident.addMainCause.EnableRule" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="Mscrm.AddExisting" />
<DisplayRule Id="Mscrm.ShowForManyToManyGrids" />
<DisplayRule Id="Mscrm.AppendToPrimary" />
<DisplayRule Id="Mscrm.AppendSelected" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addExistingFromSubGridAssociated" Library="/_static/_common/scripts/RibbonActions.js">
<CrmParameter Value="SelectedEntityTypeCode" />
<CrmParameter Value="SelectedControl" />
</JavaScriptFunction>
</Actions>
</CommandDefinition>
Enable rule def:
<EnableRule Id="my.incident.addMainCause.EnableRule">
<CustomRule FunctionName="utils.ribbon.isAddExistingDisabled" Library="$webresource:my_js/incident/common.js" InvertResult="false">
<CrmParameter Value="SelectedControl" />
</CustomRule>
</EnableRule>