ASP.NET MVC 2 and custom httpModule precedence - asp.net-mvc-routing

I have a custom HttpModule rewrite engine in an existing web application project that maps urls of the form
/tom/dick/harry/.../.../...
to a hierarchical navigation system stored in a database, ultimately resulting in a HttpContext.Current.RewritePath() call to the .aspx page that the requested path resolves to.
I'm interested in mixing MVC in with the existing app. If the MVC code works well and provides real benefit over the code behind model, how will I handle precedence between my rewrite engine and the routetable? Is the routetable referenced before the HttpModule, after? Are both called?

The routing in ASP.NET MVC is implemented as a custom HttpModule (UrlRoutingModule), so which takes precedence will depend on the order your modules are declared in web.config

Related

Cannot inherit undefined extended classes in SuiteCRM

We have an external dependency that connects to objects within SuiteCRM (custom objects that extend from SugarBean and Basic) and when we load up the application within our browser, it cannot load the Basic class, presumably because its not called into memory.
Is there a way to load all the required SuiteCRM classes into an external project, if they share the same root directory (e.g, /project is part of the SuiteCRM install)?
if you are accessing this via an external application. I would recommend using the rest / soap API to interface with SuiteCRM.
If you are trying to reuse the classes then you could do the same thing as one of the entry points like index.php, soap.php etc.
They all include entryPoint.php
require_once 'include/entryPoint.php';

Calling JSP's directly in AEM 6.2

To call JSP's in AEM 6.2 I've been creating site pages then changing the resourceType to a JSP component. Without creating OSGi bundles, is it possible to call a JSP directly without having to go through the Page / Component reference method?
In short No. That is against Sling principles. Quoting the documentation
Sling Scripts cannot be called directly
Within Sling, scripts cannot be called directly as this would break
the strict concept of a REST server; you would mix resources and
representations.
If you call the representation (the script) directly you hide the
resource inside your script, so the framework (Sling) no longer knows
about it. Thus you lose certain features.
For more information, please refer The Basics

manipulating other modules functionality in zend framework 2

How can I manipulate other modules without editing them ? very the same thing that wordpress modules do .
They add functionality to core system without changing the core code and they work together like a charm.
I always wanted to know how to implement this in my own modular application
A long time ago I wrote the blog post "Use 3rd party modules in Zend Framework 2" specifically about extending Zend Framework 2 modules. The answer from Bez is technically correct, it could be a bit more specific about the framework.
Read the full post at https://juriansluiman.nl/article/117/use-3rd-party-modules-in-zend-framework-2, but it gives you a clue about:
Changing a route from a module (say, you want to have the url /account/login instead of /user/login)
Overriding a view script, so you can completely modify the page's rendering
Changing a form object, so you could add new form fields or mark some required field as not required anymore.
This is a long topic, but here is a short gist.
Extensibility in Zend Framework 2 heavily relies on the premise that components can be interchanged, added, and/or substituted.
Read up on SOLID principles: http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
Modules typically consists of objects working together as a well-oiled machinery, designed to accomplish one thing or a bunch of related things, whatever that may be. These objects are called services, and managed by the service locator/service manager.
A big part of making your module truly extensible is to expect your developers to extend a class or implement a certain interface, which the developer register as services. You should provide a mode of definition wherein the developers can specify which things he wants to substitute, and/or add their own services to -- and this is where the application configuration comes in.
Given the application configuration, you should construct your machinery a.k.a. module services according to options the developer has specified i.e., use the developer defined Foo\Bar\UserService service as the YourModule\UserServiceInterface within your module, etc. (This is usually delegated to service factories, which has the opportunity to read the application configuration, and constructs the appropriate object given a particular set of configuration values.)
EDIT:
To add, a lot can be accomplished by leveraging Zend's Zend\EventManager component. This allows you to give developers the freedom to hook and listen to certain operations of your module and act accordingly (See: http://en.wikipedia.org/wiki/Observer_pattern)

Can we use <location> tag in web.config to refer to a controller in an MVC application

We have a requirement of restricting access to certain web endpoints in our application to a specific set of IP addresses.
In tradition web forms applications we have successfully used a combination of < location > and < ipSecurity > tags in our web.config to restrict access to our handlers (ashx). Will this same approach work for a ASP.NET MVC application where the end point is a controller/action instead. Our first attempt of just specifying the controller name in the location's "path" attribute didn't work.
The other approach is to use MVC Authorize/Filter attributes on that controller to get the right restriction in place but we would prefer to control this purely from our web.config rather than in code.
Will this same approach work for a ASP.NET MVC application where the end point is a controller/action instead.
Maybe yes, maybe no. It's a considered bad practice to use this tag in an MVC application. I would recommend implementing a custom [Authorize] filter. Of course you could still externalize and read the list of authorized/unauthorized IP addresses from web.config to ease the administration and avoid you recompiling the application if they were to change.

General question, what do you want from a web framework?

In a MVC application, what are some of the components that make up the application. What tools and functionality is missing that you would like to have. Regardless of the server-side language, what would you want?
I see a lot in my code where I code some much functionality that it seems should already be there. I looked at Google web toolkit and they seem to get it right. Widgets are widgets and you simply add them to your application.
For example. I work with J2EE apps but in other languages, the components are the same.
Controller Objects
Controller handlers, defined by methods in the controller objects.
Configuration files defining the URL mapping and settings.
Template server page files (e.g. JSP/ASP files).
Configuration files defining O/RM mapping between application objects and the database.
Configuration files defining the database connection properties.
JavaScript libraries (e.g. jQuery)
Logging configuration files
Resource message bundle files
Validation configuration files or code
Middleware components and objects (EJB configurations, JMS/Messaging configurations, etc).
Credit Card or other middleware connectivity APIs and libraries.
Anything else you can think of?
Built-in Unit Testing Component
I think one thing you're missing from that very exhaustive list is the automatic binding of request properties to form objects, and the saving of these objects to the session where appropriate. Form objects here being the object on the server that represents the current state of the HTML-based for displayed to the user.
I think scaffolding and automatic admin interfaces are very nice features too, that I dont want to miss ;)
You've made the assumption that all MVC applications are websites. MVC is widely used for more than just web apps so things like URL mappers, template server pages and "Server side" languages are not associated with the MVC pattern, so much as a particular implementation and adaptation of the MVC for use in web apps.