How to exclude web.config when publishing with Visual Web Developer Express? - vwdexpress

When using the project publish feature in Visual Web Developer Express Edition 2008. How can you exclude publishing the web.config so that it doesn't overwrite the server web.config?
I've tried setting the following in the web.config, which works for any other files ending .config but not the web.config for some reason.
<buildProviders>
<remove extension=".config" />
<add extension=".config" type="System.Web.Compilation.IgnoreFileBuildProvider"/>
</buildProviders>

I can't believe this is so simple but never got answered. I found the answer in this question
Simply select the web.config properties and change 'Build Action' to 'None' and 'Copy To Output Directory' to 'Do Not copy'

Related

Unable to open Json file on Server

I published a json file on to my website using ftp. When I tried to access my site using mtsite.com/abc.json it throws the below error.
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
My file is on hosted site on azure. Even if file in on server why did it say that file is not found?
Any place in azure portal where I can add or allow Mime type json? I cannot add web.config file as My files are all HTML and Json.
By default IIS (and so the Azure App Service) doesn't serve .json files. You need to enable this feature in your web.config. If don't already have one, create it in the root directory.
Open your web.config and place this code
<staticContent>
<remove fileExtension=".json"/>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
under the nodes
<configuration>
<system.webServer>
And it should be fixed.
Here you can find a basic web.config template that i've made a while ago
P.S: Even though you are using only HTML and JSON, this is the only way to go (as there is not a UI solution in the portal). In this way you could also control other aspect of your website, for example the redirect to HTTPS for the HTTP requests.

Why is IIS Express returning HTTP 500 errors loading javascript and CSS?

I am trying to develop an ASP.NET MVC5 solution using IIS Express for local debugging. Frequently, Chrome will report HTTP500 errors trying to load certain JS and CSS files (some using the built in bundling and minification feature of MVC, some on their own).
WTH is going on with this and how do I stop it?
Thanks,
Matthew
Turns out this was related to ninject object lifecycles and my EF db context being open twice at the same time. Totally unrelated to IIS.
What helped worked is as follows. I am using Visual Studio 2015.
Close the visual studio solution. In fact I closed the visual studio itself
In the solution folder(the folder which contains the .sln file along with the project folders), you should find a .vs folder. I had deleted that folder.
Restarted the visual studio and loaded the solution.
Things are working fine now.
The reason I guess is, the config folder inside of .vs folder has the applicationhost.config file. That is having some setting issues.
In my case, I got to remove the attribute of debug="true" in web.config compilation node.
From
<compilation debug="true" targetFramework="4.7.2" />
To
<compilation targetFramework="4.7.2" />
Then it works fine.
Old thread but still relevant in VS 2019 and the top result.
For me, I created a .NET CORE WebApp (an API), then deleted it, deleted the files it left behind and recreated a .NET Framework (API) of the same name.
Started it up and spotted it was still using the same port number
https://localhost:44379
but the basic formatting was gone and 500 errors on all the .css and .js files. After editing the .csproj file and changing
<IISUrl>https://localhost:44379/</IISUrl>
to
<IISUrl>https://localhost:44380/</IISUrl>
Changing this reset something IIS Express and the css and .js files loaded and it looked fine.

Manifest does not force Visual Studio 2013 to restart under Admin when running application in Debug mode

This worked in VS2010 and VS2012. But in VS2013 application (by pressing "Run" or F5) is just starts with my user's rights and cannot access some resources (I'm using HttpListener).
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
I tried to google, tried to generate new manifest, copied it's content from MSDN, but nothing helped. Did something changed in this part of VS2013?
Update1:
That was a part. Here is complete manifest content:
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application></application>
</compatibility>
</asmv1:assembly>
Update2:
Okey here is simple example: when I run compiled .exe file UAC asks for admin privileges. But when I run it from VS2013 (by pressing "Run" or F5) it doesn't! And if you open the same project with VS2012/VS2010, they do ask to restart under admin.
You can check this quickly:
Create console application in VS2013, add manifest and set level="requireAdministrator". Then run or press F5 (VS2013 runs the application under admin when press Ctrl-F5).
But this is not the behavior of VS2012/VS2010!
How can we get the old behavior?
Update3:
Please vote here or inform me about another ticket.
You need to disable the hosting process option to get the VS restart prompt. Project + Properties, Debug tab, untick the "Enable the Visual Studio hosting process" checkbox. It can be easier to just start VS elevated right away. Right-click the shortcut, Run as Administrator.
Not entirely sure if this is a bug or a feature. Keep your eye on this Connect report to learn more.
Update: looks like a bug, the feedback report was closed as "fixed". Unfortunately it gives no hint when that fix is going to make it our machines. Maybe a future VS2013 update, surely the next version.
Update2: the fix made it into VS2013 Update 3.
What I ended up doing is I run the project without debugging CRTL+F5 . The it gives me the same prompt that Visual Studio 2010 gives you.
I'm hoping this will get fixed soon™
In the mean time you can use handy shortcuts for restarting VS in admin mode, look up "Visual Studio Restart" in the extension gallery.
Edit:
Only way I see you can achieve the old behavior is to turn off VS hosting process as it is this process that for some reason "eats" the elevation prompt. Actually when I think about it, this behavior might even be by design. You can turn off hosting process in project properties (Debug) or when you generate .csproj set platform configuration UseVSHostingProcess tag to false, like so:
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup>

First time uploading website,how to make default web page?

i created a website using asp.net visual studio 2010 express
today i purchased a hosting program with plesk 11.
on the welcome email of the hosting services i got this line: "please be sure that your homepage is saved as an "index" file e.g., index.htm, index.html, etc
all my website is .aspx files!
also my homepage is using a master page!
they help support couldn't help me.
so i ask you can i just rename it to index.aspx and upload it as it is?
Open your web.config file and set the following property in it.
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="Path of your Page" />
</files>
</defaultDocument>
</system.webServer>

loading .json files generates 404 errors

My first Azure website is a simple test site I've had for a while that makes ajax calls back to the server for JSON data. All the data files have .json extensions. Azure will not 'see' these files. If I change the extension to .txt it servers them up fine.
Do I have to muck with IIS to get this .json to be seen?
I too found Ahmed Sabbour's blog post helpful, but it created an additional problem for me. Whilst the fix worked for the Azure Web App when I then tried to run the app locally it died horribly, throwing HTTP 500.19 everywhere. It took me a while to figure out how to fix this whilst maintaining a single web.config. The solution was (albeit a bit of a fudge) to remove the fileExtension first and then add it back in:
<staticContent>
<remove fileExtension=".json" />
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
For my narrow purposes this was fine and I hope this might save someone time trying to figure this out.
Citing Ahmed Sabbour with his blog post http://blogs.msdn.com/b/africaapps/archive/2013/06/07/how-to-serve-static-json-files-from-a-windows-azure-website.aspx you have to do the following:
"If you upload a .json file to your Windows Azure website and try to access it, it would give you a 404 File Not Found error, because the MIME Type of .json is not set by default. This also applies in general to any file that might need a specific MIME Type.
To fix this issue, FTP into your website and upload the following Web.config file which will set the correct MIME types. If you already have a Web.config file in place, just add the below to the appropriate section.
<?xml version="1.0"?>
<configuration>
<system.webServer>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
</staticContent>
</system.webServer>
</configuration>
". I did this and the 404 was gone.
It appears that Azure (Cloud Services, at least) knows how to serve JSON from a deployed ASP.NET MVC project. The problem in my case was that the Build Action on the JSON file's property page was not set correctly. Changing the Build Action to Content fixed it for me.
have you tried adding the specific MIME type to your server's config file?
http://www.iis.net/configreference/system.webserver/staticcontent/mimemap
If you add the mime type as
application/json; charset=utf
that should work.