How do I change Empty Template to Internet Template in MVC 3? - asp.net-mvc-3

A new MVC Web application has been created with Empty Razor Template. In this template I found that default controller,Model and View are missed. I need to change the template from Empty to Internet Application.
I couldn't find any option in the properties to change Internet controller. How can I do that without creating a new project?

You could create a new project in reverse. Create a new project based on the Internet template, and use a compare tool (I rely heavily on BeyondCompare) to merge the Internet template differences into your existing project.

The difference between Empty Razor Template and Internet Application Template is in two (Account and Home) Controllers, Views that go with them and in different Site.css. You can't simply "switch" between templates.
You can go from Internet Application to Empty, if you delete Account and Home Controllers and corresponding Views. Other way around is a bit more difficult. Use scaffolding to accomplish that.
You can also check differences between templates here.

Related

ASP.NET MVC 5 per user custom built views with widgets

I want to make an MVC 5 app that will allow users to customize views/pages, create new ones. On the custom pages they can set-up widgets and be able to save the views. Also they should be able to setup the default view that will be loaded by default.
Any ideas how can I achieve this? I believe the views should be saved in the database.
EDIT:
I found this template engine RazorEngine. This seams to be what I am looking for. Anybody has any experience using RazorEngine?
I think you should try some CMS like dotnetnuke etc. other wise build your own framework for all the things so that it can save and fetch your details to and from database.

what is the correct approach in order to host / integrate / show my existing MVC3 project inside orchard?

I've an existing MVC3 project that implements a certain functionality, this project has it's own views, and a separate Database.
now I'm required to use the same functionality inside one of my orchard project,so I thought that I can host this solution in somewhere and view it inside an iframe or something.
Am I thinking right?,
is this the correct step to take in order to achieve this requirement inside Orchard?
to make it more clear, all I need to do is to view this solution and interact with it's controls and views from a hosting page inside orchard, and the subsequent requests should be handled by my solution in order to hit it's own data store and get back with the requested data in order to be displayed to the user.
any help would be appreciated.
Update:
thanks for Bertrand Le Roy for his answer, I can now view my solution inside my
orchard website.
I came in to one more HUGE problem, which is that my application can no longer connect to my external database.
I've a DB that is hosted in some where else, and I'm using EntityFramework to deal with it.
the problem is that if I put the connection string inside my module web.config, or main orchard web.config, I run into several types of errors like:
"System.Reflection.TargetException: Object does not match target type."
or
"System.Data.MetadataException: Unable to load the specified metadata resource."
My question is: How could I pass my connectionstring correctly to my solution, assuming that I'm using Entity framework as my ORM.
Many thanks.
You will need to put it into a module.
You will have to move route definitions to a Routes.cs file (look at any existing such file for examples).
You will also need, in order to access your data store, to opt out of the ambient Orchard transaction around the data access code (using (var scope = new TransactionScope(TransactionScopeOption.Suppress))).
If you are using dependency injection, you may have some work to move that to the Autofac-based way of doing things in Orchard.
If you want your work to appear seamlessly in the Orchard admin, you may want to decorate your admin controllers with the Admin attribute. If you want your front-end to use the current theme, you'll have to add Themed attributes and maybe refactor your views so that they only emit HTML for the content zone instead of for the whole page.
Add a manifest (module.txt) to your module folder and you should be good to go.

MVC3 Dynamic SubDomain Routing

First of all, I have read a lot of post relating this issue like:
Asp.net MVC RouteBase and IoC ,
Tenant-specific routes for dynamically loaded modules ,
and many others.
What I want is:
- Dynamically create pages like tenant1.mydomain.com, tenant2.mydomain.com, etc.
- My tenants will have the same functionality but just different content, styles, title, etc.
I have tried extending RouteBase class but have read that is not a clean solution.
Then I have tried creating a custom RouteConstraint like above posts recommend but not succeded.
Help me!
Thanks!
I have achieved this by doing two things. 1) was to provide functionality to select the correct content by providing the repositories via a factory which was handed the URL on creation. The issue here is that it might be possible to fetch the wrong data via relationships from entities that themselves don't have a tennantid field.
2) Is a basic custom view engine which looks up the host part of the URL and would look for a client specific template (via a folder structure) if the template was found it was used, otherwise the default template is returned.
Between these two I've got a system that delivers (in my case) multiple websites via the same bespoke CMS and product management tool.

best way to multi-language asp.net mvc 3

I'm trying to create a asp.net mvc3 project for a academic project, and one of the requirements is it has to be able to change between different languages. Currently what i have is the following:
I have a external project that works as a repository for languages and for each view i have an interface for each view that defines all the "placeholders" do define all the changeable text.
At the beginning of any action i obtain the language that is in the uri (something like /{lng}/{command}/{action}) and pass it to the view using the ViewBag, once inside the view i user the repository to obtain the current implementation of the interface for that view in the chosen language.
I can't find any good topic on this mater. I'm just curios if there is a better way to do this and more efficient. And how is it normally done in a professional level.
I'm not very experienced with asp.net just started learning it about a month ago.
Also if it's important i am using the razor engine for the views, and we can't use any JavaScript in this phase of the project.
You may go through the following guide.
I'm working with a project called Griffin.MvcContrib which has some localization features.
First of all, I use the query string and a cookie to switch language. (Just create a link with a flag in your layout English)
and tag your controller with my attribute:
[LocalizedAttribute]
public class YourController : Controller
{
}
The next thing is to get localization of views, models and validation messages.
The localization of models and validations are described here. As for views, you only need to use #T() to get translated texts:
#Model.Title
<div>#T("This text will get translated")</div>
(you need to change pageBaseType in Views\Web.config to Griffin.MvcContrib.GriffinWebViewPage)
I'm almost done with an adminstration area that any non-technical user can use to manage all translations. Check the Griffin.MvcContrib.Admin project here: https://github.com/jgauffin/griffin.mvccontrib/tree/localization/source/Griffin.MvcContrib.Admin

How to use EF4 as a DAL

I am currently using EF 4 with my ASP.NET Website to access a MySql database. This works fine. However I now want another Web Site project to access the same entities. How do I set this up?
I can't just reference the original website as it's a Web Site, not a Web Application. So presumably, I need to put the Entity Data Model in its own project and compile to a DLL. But...
Which project type?
Do I just cut and paste the DataModel.edmx and DataModel.Designer.cs, compile and add a reference in both websites? What about namespaces?
Where do I put the connection string? At the moment it's in my project's Web.config.
I really have no idea where to begin - I've just followed tutorials to get EF working up to now! I'd really appreciate step-by-step instructions if anyone has time. Thanks.
The model should be placed in a new class library project. My preference would be to recreate the model at this point based on the existing model. For the namespace I like to use {CompanyName}.DataAccess. Remove the old model from your web site project, add a reference to the new class library project and build the web site project. The website project will break in many places, but it should be a simple matter of changing the namespace to the new data access assembly. I prefer this method as to cut/paste because now you have nice clean namespaces. Be careful of any places you may have strings with entity names in them, like if you were using Include (if you are using EF 4 and lazy loading, this should not be a problem). Leave the connection string in web.config for both of the web site projects. When you create the model in the class library, it will add a connection string in app.config. That is OK, it is just there so the model knows how to connect to the database when you refresh it.

Resources