Reputation: 171
I am new to Orchard CMS. I have a requirement to create an email notification to the admin if there is any error. I have made a custom module so it would send an email to admin. Also, I have put a redirection to the module from error page.
here is my code in NotFound.cshtml
in my custom theme
<script type="text/javascript" language="javascript">
function ToError() {
window.location.href = '/FourOFour?LastURL=' +
(window.location.host + window.location.pathname);
}
window.onload = ToError;
</script>
here is my custom route in the module I create
new RouteDescriptor {
Priority = 11,
Route = new Route(
"FourOFour",
new RouteValueDictionary {
{"area", "Prenagen.ErrorEmailing"},
{"controller","Utama"},
{"action","Error404"}
},
new RouteValueDictionary(),
new RouteValueDictionary{
{"area", "Prenagen.ErrorEmailing"}
},
new MvcRouteHandler())
}
So the not found page will redirect to /FourOFour
. When I test it in localhost, all things works fine. I type a non-exist page and it redirect to NotFound
then to /FourOFour?LastURL=page
. And the email is sent to the admin. When I publish it to server, the not found redirect to FourOFour, but the page is not found. How can I solve this? Please, anyone help me.
edit: It creates an infinite loop because FourOFour
is not found and it keeps redirecting to the same page.
Upvotes: 0
Views: 1927
Reputation: 4763
Is your dynamic compilation disabled?
If it is and you've copied only the files that you've changed this can be the cause of your problems.
The other thing that might be the cause of your problems is if the changes you've made required creation of new files that were added to the project. If that was the case, you should have also copied .csproj file to the server to instruct Orchard to include the newly added files in dynamic compilation.
Try to rebuild your module in release mode and copy the whole module to the server instead of only the files that you've changed and see if that works..
Upvotes: 1