This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.
Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.
Before posting questions here you might want to review the developer documentation.
I would love to find the best way to add the Referrer to the error log.
This would help me locate the problem for some of the bad links and correct them.
Example:
2011-05-20 20:19:33,149 ERROR mojoPortal.Web.PageNotFoundHttpModule - xxx.xxx.xxx.xxx PageNotFoundHttpModule handled error. System.Web.HttpException (0x80004005): The file '/crazy_page_name_that_has_MS_Word_Chars_in_title breaks_me.aspx' does not exist (Referrer: htttp://www.notmysite.com/some_parnterlink).....
I can try add this on my own, wonder if others would find it useful enough to add it into the project?
thoughts?
Yes, if it's possible to add that, I would find it very helpful! We run into the same situation fairly regularly.
Jamie
Google webmaster tools provides a report of broken links in your entire site and what pages the links are on.
Best,
Joe
Not sure how best to past the simple changes on... but here we go:
So far I modified 2 files:
Global.asax.cs: (Some small logic fix as well if (!errorObtained) then there is no need to check the HttpContext)
after line: 353
if (errorObtained) { // If we get the error, grab some info about the request string exceptionUrl = string.Empty; string exceptionIpAddress = string.Empty; string exceptionReferrer = "none";
if (HttpContext.Current != null) { if (HttpContext.Current.Request != null) { exceptionUrl = CultureInfo.CurrentCulture.ToString() + " - " + HttpContext.Current.Request.RawUrl; exceptionIpAddress = SiteUtils.GetIP4Address();
if (HttpContext.Current.Request.UrlReferrer != null) { exceptionReferrer = HttpContext.Current.Request.UrlReferrer.ToString(); } } }
if (ex is UnauthorizedAccessException) { // swallow this for medium trust? log.Error(exceptionIpAddress + "-" + exceptionUrl + "- Referrer(" + exceptionReferrer + ")", ex); return; }
if (ex.Message == "File does not exist.") {
log.Error(exceptionIpAddress + "-" + exceptionUrl + "- Referrer(" + exceptionReferrer + ")", ex); return; }
log.Error(exceptionIpAddress + "-" + exceptionUrl + "- Referrer(" + exceptionReferrer + ")", ex);
PageNotFoundHttpModule.cs:
//After Line 91
if (((HttpException)(ex)).GetHttpCode() == 404) { string exceptionReferrer = string.Empty; if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.UrlReferrer != null) { exceptionReferrer = HttpContext.Current.Request.UrlReferrer.ToString(); } else { exceptionReferrer = "none"; }
log.Error(SiteUtils.GetIP4Address() + " - Referrer(" + exceptionReferrer + ") PageNotFoundHttpModule handled error.", ex);
Joe,
I use Webmaster tools, they are definite helpful but when an error comes in, being able to quickly and exactly see where problem came from make support easier. Waiting for Google to crawl the page on low traffic sites doesn't make timely fixes easy.
Warner
Fair enough, I will add the changes you suggested.
Thanks Joe~
I have tested the code i provided in a local environment, not in production.
I would not be opposed to the referrer info being added having a toggled via appsettings if you so desire.
Thanks again Joe~