Adding images in resource file in asp .net mvc - asp.net-mvc

I am trying to develop a basic multilingual app in Asp.Net MVC 4. I don't know how to set image files for different languages. I know it has to be added in the resource file. But I don't know how to call it on the view page. Can someone help me with this?

You should store image path in .rsex file as per your language and can use it.

Related

How to serve static files from ASP.NET-MVC 4 app?

This is the first time I've ever developed an ASP.NET app.
I need to serve some static files from my ASP.NET 4 app. The trouble is, I want these files to appear as if they're at the root of the app, when actually they're several folders down. With ASP.NET Core this is easy; you just drop the files in the wwwroot folder, and the server treats these files as if they were at root. But my boss has asked me to use ASP.NET 4, instead of Core, if possible. So I need to figure out how to configure this.
This post and this post both answer the question I have, but I don't understand the answers that are given. Both answers tell me to add some functionality to the "ConfigureStaticFiles" method in my "Startup" class. But I don't have a Startup class.
So, what is the best way to do this in ASP.NET 4? Should I add a Startup class? If I add a Startup class, what do I do with my Global.asax? Or should I approach this some other way?
If you want ALL static files to be served from MVC (rather than IIS) you add this to your web.config
<modules runAllManagedModulesForAllRequests="true">
...under <system.WebServer>
further read #here
Okay.
I was able to use URL rewrites to make the files and folders in a specific subdirectory appear as if they were in the root folder. This answer provides an implementation for that functionality, although my app's architecture necessitated a slightly different configuration.
I don't know if URL rewrites are the best way to accomplish this functionality, but it's what I'm using for now.

How to retrieve all static texts from resource in a mvc website?

I want to build a multi language website. I found some resource about that but I don't know how I can retrieve texts from resource file and put it on a HTML tag.
for example I have a h1 tag and I want to get it's text from resource file and change this text according to selected language.
I mean I don't know about how to use localization in views.
thanks for help
As i do not have reputation to sent a comment yet. Here is a link on how this is done from Microsoft for ASP.NET Core MVC.
Globalization and localization
For ASP.NET MVC 5 you can check a helpful tutorial from CodeProject
You can read this article about ASP.NET Core MVC Localization by URL.
And also there is GitHub repo of implementation of that article. Project is built on ASP.NET Core 2.0.

ASP.NET MVC Displaying Static Help Website

I'm trying to add Help to my ASP.NET MVC project.
The "help" website contains static pages about the features in my ASP.NET application.
I have added the content for this website into my ASP.NET MVC project and have added a hyperlink that will open the Help in its own window.
However, when I try to access the content, the application attempts to route to the Help controller.
How do I display the help website within my MVC application?
I am not sure you can do this within the context of an MVC application. I would consider just building an empty controller with an Index action (HelpController -> public ActionResult Index()) and just return the view name (cshtml file), shouldn't be any reason you can't rename your static html file to cshtml even if you aren't using razor (although I am not 100% sure without trying that the extension change is necessary). Also I would argue that if this ever needs more functionality you have the scaffolding in place to make non-static mods. Disabling routing within the context of an MVC solution honestly doesn't make the most logical sense. The only other choice would be if you hosted it in a different IIS site (but I don't think I would recommend that unless you have a huge help library).
Use IgnoreRoute when you configre your routing, for example, create a folder "help" in your app's root. Then load it with all your html help files. Then to ignore that route:
routes.IgnoreRoute("help");
You should then be able to access it by http://myapp.com/help/whatever.html

ASP.NET MVC 3 File Structure

I apologize for the vague title - I am new to ASP.NET MVC coming from PHP, and I have teamed up with a .NET developer that has a webforms background.
When working with MVC in PHP, all of my files are visible on the server - that is to say, I can go into any of my model, view and controller files and edit any of the code remotely without a problem.
In .NET MVC, I couldn't find the controller or model files, so I asked the developer how the webpage is being put together, and he told me about how .NET compiles code into .DLL files and that I am unable to access this. I wanted to view a controller to see how it was pulling together my views, but didn't even see a controller folder on the server.
To me, something about this doesn't sound right, but I am not sure because of my lack of experience in .NET. Can someone provide input as to if this is the typical .NET scenario, and if not, what is he doing wrong? Should I take this as a red flag? Keep in mind that .NET MVC is new to both of us.
Thanks!
There is no code files because these code files was compiled into DLL files during Publish process. It's not strange - it's even better because of performance reasons. It's common scenario for all ASP.NET and ASP.NET MVC applications.
You can deploy yor application via XCopy deployment (to have all .CS files etc.): simply copy all files to destination folder. Then your site will be compiled (into App_temp destination) by runtime on first run. Your .CS files will still be in place.
You can read more about Publishing procees here:
Walkthrough: Publishing a Web Site
Publishing Web Sites

ASP.NET MVC - Missing "Convert to Web Application" option

I created a new MVC project and added some webforms pages to it in an effort to start adding new pages to my app using MVC and eventually port the old pages over as well. Everything is building and working correctly but I did notice that I don't have the "Convert to Web Application" option when right clicking an aspx file. And I think its not regenerating my designer files when I change the controls on a page.
My guess is that the ProjectTypeGuid is wrong or in the wrong order. Can someone confirm?
Old (Webforms) project file
<ProjectGuid>{4F95C3D9-228E-4BD5-9840-46224BA3EBA7}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
New (MVC) project file
<ProjectGuid>{A4690D3F-695B-4BF4-93B7-EA5B17793051}</ProjectGuid>
<ProjectTypeGuids>{603c0e0b-db56-11dc-be95-000d561079b0};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
This is so wrong on so many levels but I am going to answer you anyways in the hopes I might get an uptick or something. You have two routes with this. First route which I use all the time is put your mvc applications in their own projects. When your deploying the site drop the webforms application first, and then make a folder in that webforms application and put your mvc application into that folder. That should work like a charm for you. If you insit on having webforms and MVC Framework in the same project, then don't drop your webforms into the view folder. Create its own folder because you can not directly access your aspx pages from the views folder without making modifications to the web.config. Hope this helps.
MVC is available as a Web Project only. The VS2005 style Web Site is not supported.

Resources