I'm new to spring mvc and I'm trying to add a model I created in a different project from my web project(where I keep the configuration and the controllers).
When I say "use" this models I mean as a return value or as an input parameter from one of my controller's methods. If I use those models as a variable inside of the methods there is no problem.
The web project compiles and everything is good but when I restart Tomcat I see in the logs that he doesn't recognize the models from the other project(if they are in the web project then it's all good).
Any suggestions?
Never mind... All I needed to do it to add the external project to the web's Deployment Assembly and not only to the Java Build Path.
Thanks!
Related
I need a Solution with one main .Net Core Web Application and areas to be created, but each areas has to be a .Net Core Web Application. The reason I need this is, the projects in the area needs to have separate dll and other supporting files in the bin of Main project.
Is that possible in .Net Core ?
If so, I have tried to imply the same, but each project is created with a Main method in Program.cs, which fails my build stating "Multiple entry points in my solution".
Sounds like you need Features. This will let you group and separate your Areas into different folders and then move these into different shared projects or portable libraries. You can then reference and use these in your Main .NET Core Web App.
These are not standalone Web Applications as you asked for, but it's the best way i can think of, in order to separate the different components in your application.
There can only be one entry point in a C# program.
If you have more than one class that has a Main method, you must compile your program with the /main compiler option to specify which Main method to use as the entry point. For more information, see /main (C# Compiler Options).
Visual Studio 2015 + all updates.
Asp .Net Web application (MVC).
I start off by adding a few class libraries and separating the Asp .Net WA into layers i.e. DataAccess, Business Logic and the web project itself.
Once separated I add relevant references and everything is working as I expect it to be (i.e. the application functions as it did before I separated it into layers).
In my BL (Controllers are found here). I don't have the option to Add a Controller, like you would when right clicking the Controllers folder in the default project, so add the below line
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
to the csproj file for my class library and the Add Controller option now appears. Create a controller but throws an error which was due to not having a web.config file - add this file and all works (although it would be nice to have this library working without a web.config file).
The problem I've hit is, when the Controller is created it also adds a View template within the class library but my Views folder is located in my web project.
Have I done this wrong? Is there a workaround so when a controller is created, it also creates the Views into the correct project? Or another approach for this?
This is just a guess, but it seems like you are try to use a UI-based architectural pattern to build your business layer.
Typically, your models, views, and controllers are all maintained in the main web-app project. Any supporting functions (like your BL and DL) are added via class libraries. The Visual Studio MVC templates are built around that concept, which is why you had to manually add support with the GUID - and why it automatically creates the view.
If I may ask, why are you trying to build controllers into your BL? If you are trying to decouple your UI from your server code, perhaps WebAPI would be a better option.
UPDATE - A few helpful links
ProDinner - ASP.NET MVC Sample App
N Layered App with Entity Framework, Autofac, ASP.NET MVC and Unit Testing
Architecture Guide: ASP.NET MVC Framework + N-tier + Entity Framework and Many More
Most of your issues boil down to using the scaffold. The scaffold is great when you're just starting out or for extremely simple projects, but it quickly falls down beyond that. Specifically, adding a controller via scaffold is designed for an MVC project, so it expects to find things you'd find in an MVC project. Additionally, it creates scaffolded views in an appropriate directory in Views because, again, that's what it's designed to do.
The simplest solution, then, is to just not use the scaffolds. A controller is just a class that inherits from Controller. Nothing special there. Then, you can create the views where you want to create them.
We are updating an ASP.NET Web Site project that uses ADFS 2.0 Authentication to use the one click "Publish Web Site" deployment process. We currently have three different FederationMetadata.xml files for each environment (dev, test, prod). How do we publish these files to each environment?
We use the web config transformation files for the web.config file. But I do not believe this can be used for xml files? From the searches that I have done I found two possible responses to this, neither seem very good. First one says to delete the FederationMetadata file and manually configure ADFS 2.0 (How do I change my WCF's FederationMetadata.xml file for various deployments?). We could do this but it seems like a step backwards. The second involves creating a dummy FederationMetadata file and populating it in the global.asax.cs file. (How to deploy asp.net web application to development team via TFS when setting up ADFS authentication). This approach seems very hackish and hardly the recommended approach.
Is there a recommended approach for this? Is there something obvious that I am not seeing? Any thoughts on this would be much appreciated!
If you indeed did manage to get the web.config correct then you can generate the metadata on the fly (per request). Same code for all environments. No need for the static file.
In telegram style just for the class names: For a Forms ASP.NET application it would be an HttpHandler (for MVC a controller). In the handler you must build a ApplicationServiceDescriptor, and use a MetadataSerializer to spit out the XML. Fill it with the info from FederatedAuthentication.WSFederationAuthenticationModule (which has obtained it from web.config).
This is my first post so here goes...
I have a c# .net class library I've build and been using in production for some time now. The project (using .net framework 3.5, output type Class Library, strongly named) didn't have any non-framework/standard references. It's set to be used as a COM component and we're using it against classic ASP websites. To deploy I'm setting the Build -> Configuration Manager to Release, building, copying the bin/release/PrintJob.dll file to our web servers. I then use regasm "c:\path info\PrintJob.dll" /tlb /codebase to register this on the server. At that point our classic ASP sites can successfully create an instance of the object and use it's functionality.
Today I've been tasked with implementing a new piece of functionality (encryption/decryption) using a 3rd party .net component. I'm used to working with ASP.NET applications more so that class libraries and COM components. So I update my existing project like I would a web project. I have the new dll on my computer, I first had to give it a strong name itself so my class library would accept it, I add the reference to the customCrypto.dll file in my application, reference the namespace in my class file(s), test it, build it, and it works fine locally.
I'm attempting to deploy it using the same method as previously. I go to the bin/release/ folder, copy the PrintJob.dll file to my web servers, register it the same, and when my sites attempt to use it now, it's throwing an exception that it can't find my customCrypto.dll file (the exceptions displays the full strong name assemply attributes).
So my question is am I doing this correctly? In a web project, the customCrypto.dll file is going to be moved along with my site automatically during the publish. So the dll automatically ends up with the project no problem. But with this class library, do I need to also copy the customCrypto.dll file to the other servers? When the build happened, how come my PrintJob.dll assembly didn't include this functionality internally. How do I get the COM component PrintJob.dll to be able to use the customCrypto.dll when deployed? Since the 3rd party customCrypto.dll component is a .net component, should I somehow be adding this to the machine and using it with my application another way?
I've spent the entire day trying to find references to this but all I can find are more direct issues like how to strongly name an assembly, add it as a reference, etc. Any help is greatly appreciated.
I am trying to find a way to have my Entity Framework model in a seperate project within my ASP.NET solution.
Currently I have my DataManager project (which contains my EF model and some classes) and a second project which contains all my web project files.
The problem that I have come across is that I have a database connection string in a App.Config file in my DataManager project and the same connection string in my Web.Config from my web project. I basically have a duplicate connection string.
Is there a way to only use only one connection string in my project (preferably from my web.config)?
My only concern is that when it comes to compiling my project I will not be able to change the connection string in the App.Config contained in my DataManager project.
I would be grateful if someone could help me in the correct way of having a seperate project to contain my EF model. Or suggestions on better ways.
Many Thanks!
In my project I have my EF in a domain layer and my UI in a seperate layer. The UI contains the webconfig file which in turn has the connection string that EF uses. So yes it's completely acheivable. My webconfig will superseed the app.config setting.
My suggestion it terms of layering your app would be to look at some DDD. I'm using EF4 in conjuction with MVC and the repository pattern, which seems an elegant fit. I'm not saying you need to use MVC, but it's certainly worth looking at having a domain layer for ef4.
This is the application I've used as my guide. Note this is based around mvc, but the domain aspect could be true of any application http://mvcsamples.codeplex.com/