We´re developing an ASP MVC application witch the View (aspx) has a Flex embed. This aspx/flex view is composed by a flex application and several modules.
So, when we call the application url (http://localhost:9090/MyProject/Flex/Index), the server invoke the method the will return the ActionResult that represents this action, in this case the ~/Views/Flex/Index.aspx (with the Flex app). However when the ModuleLoader, in the Flex application, try to load a module an error occurs. The problem is that the Flex application can´t directly access the modules folder (~/Views/Flex/modules/module.swf).
Are there any way to get the module through an ASP MVC action? Or the best approach is to allow the access to this folder through web.config?
Again, sorry for the poor english!
Thanks,
André
The views folder should be used for aspx/ascx views. You'll want to put .swf files in in a content folder like ~/Content/modules/module.swf.
Related
I'm building an application using ASP.NET MVC and Angular JS.
The point is to use angular for all web things and ASP.Net for backend stuff. In other words, I kind of bypassed the whole view of MVC and used a single view. Angular will get his files from the Content folder.
Those files are .html files and this seem to be a problem because I always get a 404.
Actually I also tried renaming it to .cshtml but that does not fix the problem..
Do you know of any tricks (well, clean ones of course) to let my angular app download it's views and be happy?
Thanks.
Georges
The problem most likely is in the fact that ASP.NET MVC tries to filter the request through the routing mechanism, and obviously there is no route for HTML files. Try adding the following to the routes registration method:
routes.IgnoreRoute("{file}.html");
I have an existing ASP.NET web site running on .NET 4.5. I need to integrate an ASP MVC 4 project (which is its own fully-functional web application) into it so that when the user navigates to a certain page, the ASP MVC application is launched within the page - almost as if it were in an iframe.
In the main solution I can set both as startup projects, but this is obviously not what I am looking for. Can someone point me in the direction of how to do this? I have never used WCF before, but is this something that it could be used for? Thanks for anything!
You can create a hybrid webforms - MVC application.
To do this you need to:
copy the MVC configuration from the web.config of a new MVC project to your WebForms application web.config
create the standard MVC 4 folders (at least Views, Controllers)
reference the required assemblies
copy the web.config inside Views from the MVC project to the WebForms project Views folder
change the routing configuration to ignore routes including .aspx/.ascx, so that they are handled by web forms, and not MVC (do this also for .ashx, .asmx, or whatever other web forms based artifacts)
This way you have a single ASP.NET application which supports MVC and WebForms, and use the same authentication, session, and so on.
Then you can make this kind of integrations:
- make pages that are fully MVC or fully webforms. If you're using master pages, you need to create a master page for web forms, and a layout for MVC (this can be very hard or quite easy, depending on its content and design)
- make a webforms page and integrate the MVC pages using AJAX and MVC partial views
Aprt frommy comments, this blog entry will help you a lot: Integrating ASP.NET MVC 3 into existing upgraded ASP.NET 4 Web Forms applications
By the way, this is not theoretical... I have a web application with lots of pages, areas, and views, which uses this technique, and it works flawlessly. I had to redo the design of the master page (layout and CSS) so that both kind of pages look alike. I was lucky enough to have a menu rendered in a webforms placeholder using a SQL XML query and an XSLT, so re-using it in the MVC layout was absolutely easy. You can do something similar to this in your master page and MVC layout (I mean rendering the HTML manually, and using it in both pages, so that it's done only once)
You can take some time to get it to work, but it's worth the effort.
I would like to subclass an ASP.NET control, like UpdatePanel, and use the subclass in my web site. I know if I move the code to a separate assembly I would be able to reference the assembly from within Register phrase but I wonder if there is a way to keep all the code inside the website.
Would appreciate to have your help.
Sure, you can put code files in App_Code if you are using the web site project template, or if you are using the web application project template, the code can be within a folder in the web site.
Note that the name of the assembly in web site project templates is App_Code, and for web app projects its the name defined as the assembly name in the project settings.
Do you know which template you are using?
When it comes to custom controls, sometimes you may run into issues, especially if you want to change the existing behavior of updatepanel.
HTH.
I have 2 web application projects. One is my asp.net MVC app and the other is for the admin related functions which is asp.net web forms Dynamic Data. My MVC app would be the main site, but I would want the webforms to work under an Admin folder of the MVC site.
While debugging the application, I would like the "/admin/Default.aspx" link on the MVC site to link to the default page within my Dynamic Data site. How do I accomplish this? I know I can test each project independently.
Within the visual studio project, you can right click on a folder and select "Convert to Web Application" which resolved my issue.
The easiest way would be to run them both in separate virtual directories and use Url Rewriting to push requests for the root to the public site. You can nest ASP.NET applications, but that generally requires quite a bit of fussing with the configuration file to dodge inheritance issues.
You could achieve this behavior via your IIS-Manager. Click on the Website, navigate to the folder you want to behave like a separate application and use right-mouse click and press "convert-to-application".
Is it possible to create a .xaml (silverlight) control in a web application project?
I have an aspx application wherein I am using ajax controls and updatepanel. I want to create some silverlight controls in the same project, and load it along with my other pages/controls.
I am not sure if it is possible to create a silverlight control without having a dedicated silverlight project template.
I think your question is the same as one of mine: Is there a way to insert Silverlight XAML into my page using ASP.NET code-behind?
If so, the answer is basically "not in any sane way, but you can hack it by setting up different parameters (as in weiqure's answer) and using them to dynamically generate the XAML."
I'm not sure if this answers your question, but you can have a solution file that contains your web app and a Silverlight control. Then, to include the control in your web app, add it via the "Silverlight Applications" tab in the web app's project configuration. This will auto-update the .xap file in the web app's ClientBin folder.
Alternatively, you can create the Silverlight control in its own project/solution outside of the web app solution. Then you just need to copy in the .xap file to the web app's ClientBin and add it to your aspx page the usual way. I've found this approach useful when I want to deploy the same control to multiple web sites/projects.
Instead of creating several controls you might try creating one control that dynamically creates it's own content.
You can tell the control what to do by passing initialization parameters to it. Here's the MSDN tutorial and here's a blog post about it.
I think this approach is no worse than creating controls dynamically. You can probably send it XAML markup (I'm not sure if I remember that correctly, though), otherwise you could path something like "myButton=Type:System.Windows.Controls.Button;Content=Click me!" and then use reflection.