Following this answer, I've enabled serving JavaScript and CSS from my Views folder which is helping my project's organization. Unfortunately, while I'm developing, I find I have to disable my browser cache in order to see my changes. I'd like to be able to develop without keeping DevTools open just to disable the cache.
I figure my issue is the System.Web.StaticFileHandler serving up the files in such a way that the browser caches them. I've tried using System.Web.Handlers.TransferRequestHandler like this answer suggests, but then I get 500 Server Errors instead.
Is my understanding of the problem correct? How can I resolve my issue?
Note: Not that it's relevant, but I intend to add a config transform to switch back to the static handler for releases.
Related
I have a C# Windows Store App with a WebView which loads some local HTML. I do this via the NavigateToString method. I want to include jQuery but so far the only way I can get this to work is either using the ajax hosted libraries or pasting the entire library into a script tag on the same page.
I've tried putting it in the Assets folder, ensuring that its set to Content / Copy If Newer, and I've tried the following paths to it with no success
Assets/jquery-2.1.0.min.js
/Assets/jquery-2.1.0.min.js
./Assets/jquery-2.1.0.min.js
~/Assets/jquery-2.1.0.min.js
ms-appx:///Assets/jquery-2.1.0.min.js
I've tried putting it in a /js subfolder in the app, as I've seen this done in some examples online. I've also tried adding JQuery through NuGet. Neither of these steps really made sense to me and they obviously didn't work, but I thought they were worth a try.
As usual, I got the inspiration to try one more thing while finishing up my StackOverflow question. This works:
ms-appx-web:///Assets/jquery-2.1.0.min.js
This URI Scheme ms-appx-web is mentioned in this msdn post, but it doesn't explicitly state in which cases it should be used over ms-appx:. I guess accessing local resources from a WebView is one of those cases.
Using ASP.NET 4.0, IIS 7.5.
I have a website engine, I have just implemented a way for this to tell if it's being loaded on mobile and instead of loading Controls\MyControl.ascx it loads Mobile\Controls\MyControl.ascx. This works well for my controls and also my MasterPage.Master file.
What I can't figure out however is how I can do the same with Default.aspx. This needs to be done on the fly programatically as I need to be able to check if it's mobile version. I was thinking of doing something on a pre-init event in globals but not sure if that's the best way.
Note: I don't want to use inline code on Default.aspx and just display different content base on my Mobile flag as my scenario goes one step further by basing the file on customer as well and this would mean having one huge Default.aspx for all customers which wouldn't be manageable.
Changing the default document on the fly is not possible in any practical sense.
Writing to the web.config on the fly to load a mobile version of a default page is quite frankly terrible and not an answer to the true context of your issue. I would feel irresponsible as a developer if I even proposed this as an answer to loading a mobile version of a default page.
I was trying to help you solve your problem and not just answer the base question in the title. As we all know, changing the web.config will restart your application and would not serve as a true solution, as you could not do this and achieve any kind of performance.
Here is the BEST alternative (IMHO) to dealing with mobile browsers.
http://51degrees.codeplex.com/
HTH!
For anyone else looking at this I have found a solution but I am not sure I will implement it as I don't like the idea of updating the web.config file at run time. Using the Microsoft.Web.Administration namespace you can update the server.webServer -> defaultDocument section programmatically. Doing this allows you to change the path to default.aspx and it will load based on the variables you set.
This link should provide more information: http://blogs.msdn.com/b/saurabh_singh/archive/2007/11/24/accessing-iis-7-0-features-programmatically-from-configuration-file-s-c.aspx
Also, the Microsoft.Web.Administration dll isn't available directly in VS so you need to add it from %windir%\syswow64\inetsrv (64bit version).
I was integrating the blogengine 2.0.what i did is
created folder inside my project called blogs.
copied all the files from the blogengine.net 2.0 (web).
made changes in the web.config and changed master page path.
as per
http://www.ajaymatharu.com/integrating-blogengine-into-an-existing-site/
4.while running the project it is showing the error in styles.
the screen shoot of the error is...
screen shoot of the project solution explorer is.
web.config file...
Probably not the answer you're looking for but I would go the sub-domain route and avoid all of these issues completely. Also makes it easier to maintain and upgrade. Every time there is a BE upgrade you potentially face similar issues by trying to integrate it into an existing site.
Here's one I did already: http://homenetdirect.com/
All I had to do was customize the blog CSS to match that of the parent site - you might even create a "complimentary" design...
I've got some controls on a web page that surface configuration elements of my web application.
I've wired up to their "OnChange" events, to capture value changes and so on. For each on change, I would like to say Configuration.Save(), but apart from getting "access denied" exceptions on web.config, I suspect this could be some weirdness, in trying to save to the configuration file for each control's onchange.
Any suggestions for the best way to handle this?
Would you add some detail as to what type of settings you are trying to update? I really don't think you want to save changes to your web.config from the application. Does the application have a database you could tie your saves to? That seems more appropriate for a changes you would want to make regularly, and in a transaction safe manner.
I still think this is better done using a database. But, if you must, then I'd check out this guide to working with web.config.
From an architectural standpoint, it would be better to save the changes to the configuration file when the page is submitted. However, it is likely that the web.config file is locked when the application is started.
Consequently, if you have application-specific changes that you would like to save, it is better to find a method other than web.config for saving them.
You would want to find an alternative to modifying the web.config file directly. Doing so causes your application to restart. Either generate your own XML file or a database configuration set up.
I currently have an ASP.NET web application that is serving multiple clients from a single codebase. We use URL rewriting to detect which client is being served (pretty much a virtual vdir) and that drives which master page/themes/module version to run.
Right now, each client can have a different version of a module or the default module. A module may consist of a catalog (grid) of data with various links to other modules, or it can be a chart generation module with options for which data is pulled. The modules need to be themed and localized...
Right now, we make ascx controls (/modulename/clientid.ascx) that are a part of the website's solution. If we haven't registered a control for a client, the default is used. To publish an update to any module a full publish must take place. This can be an issue if a different client has work that isn't ready to be published. For the rewrite I'd like to address this. I'm just not sure what approach to take for this. Can WCF be used here? Maybe add-ins? Each client's implementation is its own dll?
Thanks
you might want to have a look at making the client controls proper skins that just style/load the rest of the control.
so possiblly a base control that all the client controls load (per module) then the client controls are simply markup, this would mean you only need to change the markup and not to code (so you dont have to build everytime)
"To publish an update to any module a full publish must take place" - this is a problem you need to address in your architecture.
Look to de-couple your modules from the rest of your code.
Putting your modules in their own assemblies may be the key to this, as you touch on in your question. This could be addressed by writing your own Server Controls rather than User Controls as Server Controls don't require an ascx file.