Web Forms :: Share Edmx Betwen .NET Projects And C# Class Library?
Jun 15, 2010
I had two seperated projects that used the same database, similar methods, etc. So i've created a new solution and added those two projects.I've created an C# Class Library project and i've writed there all the methods from the other two. I've also created an edmx file for DAL layer. I've added the reference of the C# Class Library projects to others two but now i'm having an problem.When i try to connect to database i get the error message: "The connection specified wasn't founded in aplication, doesn't destinate to be used with the EntityClient or isnt't valid" (i've translated this from Portuguese, so it's 100% correct).
My company has several class libraries we use in multiple website projects (not web application projects). Website projects don't have .sln files, but I'm sure I've read in my past research that you can make a blank solution and put your website and class library projects in it. After answers to my previous questions, this is the direction that I'm going (based slightly on [URL]
Then I planed on using svn:externals to copy /library1, /library2, and so on into the working_copy/websites/website1/ folder. I want my team members to be able to checkout the /trunk folder for website1 and get a .sln file, /library1 external, /library2 external, etc. I want that .sln file to contain the website1 website project, and all of the library external projects. Hopefully that would look something like:
/working_copy /websites /website1 /trunk /website1 /library1 (svn:external of libraries/library1/trunk/library1) /library2 (svn:external of libraries/library2/trunk/library2) /etc. website1.sln
So, at the end of all of this, the goal is that my teammates check out the trunk, open the solution, and everyone has the exact same solution. When we commit, everything is committed appropriately to subversion (the website code, and the libraries are committed to their appropriate place on the repo). How have others solved these issues? How can I make a .sln file that my team members and I can share in this manner?
I have created two websites ,such as [URL] and [URL]; The two websites both use SQL Sever Session Mode and they use the same database for sessionstate management.
in [URL],I have a controller as below:
public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Welcome to A Site!"; Session["User"] = 123; return View(); } }
[URL] I have a controller as below:
public class HomeController : Controller { public ActionResult Index() { if (Session["User"] != null) { ViewBag.Message = "Welcome to B Site!" + Session["User"].ToString(); return View(); } else { ViewBag.Message = "Welcome to B Site!" ; return View(); } } }
if I access [URL] first ,then access [URL], I will get the response :Welcome to B Site!123 if I access [URL] first,then access [URL] then access [URL],I will get the response:Welcome to B Site.
I'm searching an answer to this question on the web for 2 weeks unsuccessfully.I'm sure I'm not the only one to wondering about that! I have two web projects MVC2: a FrontOffice and a BackOffice.
The user has to be able to upload some image in the BackOffice, which will be display on the FrontOffice and vice versa. How can I share an image folder between these two projects? Has the folder to be necessary in the solution or can it be somewhere else on the server? My team and I are working with TFS.
I want to create an image folder in which we can write and read from frontoffice and backoffice. But I don't want to have to do a "get latest version" everytime someone is adding an image in the folder. I would like to create a folder on the server we can access from the backoffice AND the frontoffice with reading and writing rights in real time. I'm not sure to be very clear.
We have a solution with multiple web projects, and there are some pages that should be present in several of them. So we'd need some sort of a shared project which contains aspx files, and which can be referenced by other web projects.
Now there are a few implementations out there:
One implementation described by ScottGu which involves building the shared project, and than copying the output aspx into the host project, and referencing the dll of the aspx. This method has the disadvantage that if the apsx gets modified it must been recopied.
Another option, based on David Ebbo's post would be to convert the aspx into ascx-es which can be referenced as custom controls, and than include those custom control aspx-es into the host project inside of some placeholder pages. (This solution seems to be the most promising) But the concerns are: can all apsx pages transformed into an ascx? I mean there's no Page.LoadComplete to give an example.
And yet another option is to use virtual directories that map into the shared webproject, as described in a Microsoft KB article. The problem again with this method is that the shared aspx-es must be in predefined directories(that is the virtual directory). If the name of virtual directory overlaps a physical directory, the virtual overrides it and no pages from the latter can be used. Is it perhaps possible to merge these two together?
Now, I've refactored my code to have a data layer, business layer and the main project as the view layer. Next I'd like to split this big project smaller projects based on discrete functionality. As I understand it, one way to handle a shared masterpage is to copy it into each project, that's not the worst thing, it hasn't changed in over a year and if it does it's easy enough to propagate the changes out to the other projects.
I was also reading that I could create an assembly from my master page and share it that way. My masterpage.aspx has a reference to a asp.net sitemap, Unlike the masterpage I'd like to maintain only one site map if possible.
I have this Control directive in a usercontrol (i've changed the namespace and class name):
<%@ Control Language="C#" AutoEventWireup="true" Inherits="Namespace.Path.To.ClassName" %> <asp:TextBox runat="server" ID="txtComment" TextMode="MultiLine" ValidationGroup="comment" /> ClassName is a class that lives in a class library and this is the class: namespace Namespace.Path.To { public class ClassName : System.Web.UI.UserControl { protected System.Web.UI.WebControls.TextBox txtComment; protected void Page_Load(object sender, EventArgs e) { HttpContext.Current.Response.Write(txtComment == null); HttpContext.Current.Response.End(); }
This not an 'MVC' question per se, but this is the closest forum I could find. I am building web/wpf/silverlight front end on the MVP pattern. I am using EDMX and a 'business logic' class to form the model, a presenter project, and a view project.The IViews contain the basic structure of each entity, the presenter contains actions, etc.Sample view:
[Code]....
Sample presenter:
[Code]....
QUESTIONS:I seem to end up with a 1-1 mapping of views and presenters. SHould there be more than one view per presenter, or more than one presenter per view? Should the presenter for an entity (in this case a User) also contain methods for functional items such as searching for a filtered list of Users using overloaded methods, etc.?Should the IViewXYZ interface contain any events or actions (methods)?
Is there a way to share class files across web site projects without actually making a physical copy of the file to the App_Code folder of each project?
I recently started explore MVC and just tried some samples around, i.e. MvcMusicStore.
As the sample DB in MvcMusicStore is quite small, I am wondering how should I design the edmx/entity for a bigger database, let say for an enterprise application, which has more than 20 tables as in AdventureWorks?
Thus, the question is should I include all in one edmx/entity or I should include multiple edmx/entities when I designing the model?
Can anyone tell me how to show alert message inside the .cs file of class library project in c#? I am calling a method of cs file in classlibrary project. Whenever the control comes to the alert message statement inside the method, alert message should be shown on the web page(aspx) and the next statement to the alert message statement should not be executed.
I am getting some memory issues, not entirely sure but does anyone think this could be the issue.On the itemdatabound event the following code runs, and it calls a shared class method Return Image which resizes the original image. Could the coding be the issue for the memory problem. There are about 10 or so items.
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
I might be asking a dumb question, but I have a client for whom I need to build many websites (10+) (asp.net 3.5) which will all the pages on each site will have the same codebehind, but the sites will launching in different regions and whilst following the same template, will have different content.I have built and launched site 1, and sites 2, 3 & 4 is nearly live, but it occurs to me that as all the sites are basically the same, the code is going to get more complicated to update as it will be duplicated, so if I need to do a bug fix on one site, I'll need to do the fix on all websites (and this is going to get complicated.)
I was wondering if it possible to somehow create a class library of all the current aspx.cs files, reference this dll in each website and then inherit these classes into the .aspx.cs files. So default.aspx in each site would still have a CodeFile of "Default.aspx.cs", but Default.aspx.cs would inherit the corresponing class from the dll:
using WebPagesClass; public partial class _Default : WebPagesClass._Default { }
The reason for doing it like this is that if I need to change any code on a specific website (for minor changes in languages for instance), I can override the page functions and change the parts required. For all other pages which have not cha, I can just copy from a single website.Is this vaguely possible? If not anyone one got any killer suggestions of how to manage so many websites from a single codebase?
because of i want to use some cods in difrent projects i create a class library and i write my codes there but i don't have access to my controls event in this example i try to check something befor the user login to website and if there is an error show the user a clear error message
[Code]....
in this case because of my codes are in class library the event for MainLogin.LoggingIn doesn't work and it return an error that it doesn't understand the MainLogin.LoggingIn event.
I would like to learn to use Validations from a class library in my projects. I am trying to create a simple project, so when a button is pressed a validation from a method in the class library checks to see a textbox on my ASPX form if it has a valid integer in it and a label message display true/false. How abouts would I get this?
I know this 'dyanamic control event not fired' has been raised time and time again, but I still can't work out how to solve this issue...
I'll break down the parts and where the button is created without the 'flesh' around the code that shouldn't have an effect.
Imagine this is the stack:
[Code]....
button_Click never gets fired. The annoying thing is in the app, if button list isn't used, RadioButtonList is and is attached in exactly the same way and while i haven't checked, i'd imagine I would be able to catch events from that.
I have a web Application and have created a seperate class library project.I am trying to use the Class Library by referencing it in the Web Application. I am doing this by right clicking the web application and clicking 'Add Reference...'. I then browse to my Class library and click ok. This gets added to a Bin folder in my web application.The problem is I can't actually get any of the objects that are in the Clas Library. I have tried adding a using statement to the top of the page. It tells me that the object could not be found (are you missing a using directive or an assembly reference?)Can anyone tell me what I'm doing wrong?
I'm working on an ASP.NET MVC application, but I'm trying to remove everything but Controller code from my project and put it in it's own Class Library. I've got some code that is using System.Web.Mvc; But it doesn't seem to be letting me access it. I have Referenced the System.Web Namespace in the project. Bassically I'm getting errors on the iActionFilter and the FilterAttribute stuff.