PeterSinger
asked on
Modifing the Exchange owa error.aspx
Hi,
I would like to modify the "auth/error.aspx" for the exchange owa 2010 to do something special for one or two of the errors that can be returned to the aspx.
Below is the error.aspx.
I do not know enough about what would need to be changed in the code to do two things.
1. Report the error exact error number to the user page so I can then set a redirect if that error occurs
2. Then set the redirect if that error occurs in the error.aspx
Could I ask for help on how to code this.
I attach the content of the aspx file.
Thanks
I would like to modify the "auth/error.aspx" for the exchange owa 2010 to do something special for one or two of the errors that can be returned to the aspx.
Below is the error.aspx.
I do not know enough about what would need to be changed in the code to do two things.
1. Report the error exact error number to the user page so I can then set a redirect if that error occurs
2. Then set the redirect if that error occurs in the error.aspx
Could I ask for help on how to code this.
I attach the content of the aspx file.
Thanks
<%@ Page language="c#" Codebehind="Error.aspx.cs" AutoEventWireup="false" Inherits="Microsoft.Exchange.Clients.Owa.Core.Error" %>
<%@ Import Namespace="Microsoft.Exchange.Clients" %>
<%@ Import Namespace="Microsoft.Exchange.Clients.Owa.Core" %>
<%@ Import Namespace="Microsoft.Exchange.Clients.Owa.Premium" %>
<!-- {698798E9-889B-4145-ACFC-474C378C7B4F} -->
<html dir="<%=(SessionContext != null && SessionContext.IsRtl) ? "rtl" : "ltr"%>">
<% // Any urls to resources in this file, must be absolute urls. The error page can load as a response to any request
// made by the client, since it does by an internal redirect on the server and not as a 302 issued to the client.
// Therefore, there is no way of knowing where a relative url will take you. For example, this page can load as a
// result of this request "http://servername/owa/auth/logon.aspx" or this request
// "http://servername/owa/ev.owa?oeh=1&ae=dostuff"
//
%>
<head>
<meta http-equiv="Content-Type" content="text/html; CHARSET=utf-8">
<title><%= LocalizedStrings.GetHtmlEncoded(Strings.IDs.ErrorTitle) %></title>
<link type="text/css" rel="stylesheet" href="<%=ResourcePath%>14.1.287.0/themes/base/premium.css">
<link type="text/css" rel="stylesheet" href="<%=ResourcePath%>14.1.287.0/themes/resources/<%= Utilities.GetDefaultCultureFontCssFileUrl(OwaContext) %>">
<style>
<% if (Utilities.IsViet()) { %>
body, html
{
font-family:Helvetica, Tahoma !important;
}
<% } %>
</style>
<% if (ShowSendReport || RedirectForFailover)
{ %>
<script type="text/javascript">
<% Utilities.RenderOWAFlag(Response.Output); %>
</script>
<script type="text/javascript" src="14.1.287.0/scripts/premium/uglobal.js"></script>
<script type="text/javascript">
<% if (ShowSendReport) { %>
<% RenderingUtilities.RenderCanaryParameters(Response.Output); %>
<% /* Send error report only for premium */%>
function rprt()
{
var oDivSR = $("divSR");
oDivSR.detachAllEvents("click");
var sE = null;
var rgE = items("exceptionType");
if (0 < rgE.length)
sE = Owa.Dom.Node.wrapDomNode(rgE[0]).get_TextContent();
else
sE = "no exception";
var oR = new oeReq("Error", "SendReport", null, cbRprt);
oR.add("s", "Error Report: " + sE);
oR.add("b", $("divDtls").get_TextContent());
$("spnRS").set_TextContent("<%=LocalizedStrings.GetJavascriptEncoded(Strings.IDs.SendingReport)%>");
var oImgSts = $("imgSts");
var sSrc = oImgSts.getAttribute("src");
oImgSts.setAttribute("src", oImgSts.getAttribute("prgrs"));
oImgSts.setAttribute("prgrs", sSrc);
oR.send();
}
function cbRprt(oR)
{
if (oR.sErr)
$("spnRS").set_TextContent(oR.sErr);
else
$("spnRS").set_TextContent("<%=LocalizedStrings.GetJavascriptEncoded(Strings.IDs.ReportSent)%>");
$("imgSts").setAttribute("src", $("imgSts").getAttribute("prgrs"));
}
<% } %>
<% if (RedirectForFailover) { %>
window.onload = function window$onload()
{
var oSpRedir = document.getElementById("spRedirUrl");
if (oSpRedir)
{
setFlrReTimer(
(typeof(oSpRedir.textContent) == "undefined") ? oSpRedir.innerText : oSpRedir.textContent);
}
}
<% } %>
</script>
<%}%>
</head>
<body id="errorAspx" class="err">
<% if (SessionContext != null && !SessionContext.IsProxy && SessionContext.IsBasicExperience){ %>
<table id="tblErr" cellspacing=0 cellpadding=0>
<tr>
<td>
<table cellpadding=0 cellspacing=0>
<tr>
<td align="center" valign="middle"><img src="<% Microsoft.Exchange.Clients.Owa.Basic.RenderingUtilities.RenderOwaBasicLogo(Response.Output, SessionContext); %>"></td>
<td class="w100"></td>
<% if (ErrorInformation.ShowLogoffAndWorkButton) { %>
<td nowrap id="tdErrLgf"><a href="logoff.owa?canary=<% Utilities.HtmlEncode(Utilities.UrlEncode(Utilities.GetCurrentCanary(SessionContext)), Response.Output); %>"><%= LocalizedStrings.GetHtmlEncoded(Strings.IDs.LogOff) %></a></td>
<% } %>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="w100" cellpadding=0 cellspacing=0>
<tr>
<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerTopLeft); %>"></td>
<td id="tdErrHdTp"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerTopRight); %>"></td>
</tr>
<tr>
<td colspan=3 id="tdErrHdCt">
<div class="errHd" id="errMsg"><b><% RenderError(); %></b></div>
<% if (SessionContext is UserContext && ErrorInformation.ShowLogoffAndWorkButton && !RedirectForFailover) { %>
<div class="errHd"><a href="<%= UserContext.LastClientViewState.ToQueryString() %>"><%= LocalizedStrings.GetHtmlEncoded(Strings.IDs.ErrorClickToContinueWorking)%></a></div>
<% } %>
<% if (HasErrorDetails){ %>
<div>
<table id="tblErrHdDsc">
<tr>
<td><img src="<% Response.Write(ResourcePath); RenderIcon(); %>"></td>
<td class="w100" id="errDt"><% RenderErrorDetails(); %></td>
</tr>
</table>
</div>
<% } %>
</td>
</tr>
<tr>
<td colspan=3 class="errHk"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="tdErrDbg">
<% } else { %>
<table class="errDesc" style="margin-top:24px"> <% /*The margin-top here is a hack so that the error string doesn't cover the notification bar. This would be fixed once we change the IFrame layout*/ %>
<tr>
<td style="width:1%"><img src="<%=ResourcePath%><%RenderIcon();%>"></td>
<td id="errMsg"><% RenderError(); %></td>
</tr>
<% if (HasErrorDetails) { %>
<tr>
<td id="errDt" colspan=2>
<% RenderErrorDetails(); %>
<% if (IsExternalLinkPresent) { %>
<br><% RenderExternalLink(); %><br>
<% } %>
</td>
</tr>
<% } else if (!HasErrorDetails && IsExternalLinkPresent) { %>
<tr>
<td id="errDt" colspan=2><% RenderExternalLink(); %></td>
</tr>
<% } %>
</table>
<hr class="line" size="2">
<% } %>
<% if (ShowDebugInformation) { %>
<% if (!IsDownLevelClient) { %>
<% if (ShowSendReport) { %>
<div class=act onclick="rprt()" id=divSR>
<img id=imgSts src="<%=ResourcePath%>14.1.287.0/themes/basic/send.gif"
prgrs="<%=ResourcePath%>14.1.287.0/themes/base/pgrs-sm.gif">
<span id=spnRS><%=LocalizedStrings.GetHtmlEncoded(Strings.IDs.SendReport)%></span>
</div>
<%}%>
<% if (Utilities.GetBrowserType(OwaContext.HttpContext.Request.UserAgent) == BrowserType.IE) { %>
<div class=act onclick="window.clipboardData.setData('Text', document.getElementById('divDtls').innerText)"><img src="<%=ResourcePath%>14.1.287.0/themes/resources/copy.gif"> <%=LocalizedStrings.GetHtmlEncoded(Strings.IDs.CopyErrorDetails)%></div>
<%}%>
<%}%>
<div class=act onclick="document.getElementById('divDtls').style.display='';this.style.display='none';"><img src="<%=ResourcePath%>14.1.287.0/themes/resources/expnd.gif"> <%=LocalizedStrings.GetHtmlEncoded(Strings.IDs.ShowDetails)%></div>
<br>
<div id=divDtls style="display:none"><% RenderDebugInformation(); %></div>
<% } %>
<% if (SessionContext != null && !SessionContext.IsProxy && SessionContext.IsBasicExperience){ %>
</td>
</tr>
<tr>
<td>
<table class="w100" cellpadding=0 cellspacing=0>
<tr>
<td colspan=3 class="errHk"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
</tr>
<tr>
<td colspan=3 id="tdErrFtCt"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
</tr>
<tr>
<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerBottomLeft); %>"></td>
<td id="tdErrFtBt"><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.Clear1x1); %>"></td>
<td><img src="<% SessionContext.RenderThemeFileUrl(Response.Output, ThemeFileId.CornerBottomRight); %>"></td>
</tr>
</table>
</td>
</tr>
</table>
<% } %>
</body>
</html>
It's a bit tricky, because the error message is produced by compiled code that you can't see. As you can probably guess, it is produced by the function RenderError(), but it isn't likely that you can get to see the actual error code for yourself. One thing you might try is to use JavaScript to inspect the text once the page has been sent to the user. To see if this is likely to work, try adding this just before the </body> tag at the bottom:
<script language="JavaScript">
alert(document.all.errMsg. innerText) ;
</script>
Hopefully, it will show a popup box with the same error text in it.
<script language="JavaScript">
alert(document.all.errMsg.
</script>
Hopefully, it will show a popup box with the same error text in it.
ASKER
Thank you so much for you reply. That did pop up a box with the error
So could I now jast say if the error contains the words "A mailbox couldn't be found for PROD\ whatever is next" do a refirect to :https://something?
How would I do that with a javaScript?
So could I now jast say if the error contains the words "A mailbox couldn't be found for PROD\ whatever is next" do a refirect to :https://something?
How would I do that with a javaScript?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI. It did not do anything. Do I need a * or something to get the part of the error? Also do I need to use an absolute url or can i use https://servernams/dir/
ASKER
<script language="JavaScript">
if(document.all.errMsg.inn erText.ind exOf("A mailbox couldn\'t be found") != -1)
window.location = "https://owa.ugllimited.com/owa";
</script>
It needed an escape for the '.
Working now. Thank you so much :)
if(document.all.errMsg.inn
window.location = "https://owa.ugllimited.com/owa";
</script>
It needed an escape for the '.
Working now. Thank you so much :)
ASKER
Fantastic
ASKER
Open in new window