Visual Studio keeps adding IIS Express back into my launchsettings.json - .net-core

I am trying to remove the IIS Express profile from my .NET Core launch settings but every time i repoen the solution, Visual Studio adds it back in again. For example, in a new project my launch settings looks like this
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:55735/",
"sslPort": 0
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"MyProject": {
"commandName": "Project",
"launchUrl": "http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
I remove the IIS sections
{
"profiles": {
"MyProject": {
"commandName": "Project",
"launchUrl": "http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
The solution runs fine. But as soon as I close and reopen the solution the IIS sections reappear.
Any ideas?

UPDATE:
The issue should be fixed with the latest release (update) of Visual Studio 2017 (version 15.3.0).
Initial answer:
This is not a solution, but an ugly workaround. I figured that if I would just deny permissions to change the launchsettings.json file this will prevent Visual Studio from overwriting it every time. Since this file doesn't change much, it is more or less a satisfying solution for me.
So:
Update your launchsettings.json for the last time.
Close Visual Studio.
Open security settings (right-click on launchsettings.json in Explorer -> Properties -> Security)
Click Advanced -> Change Permissions
Select "Authenticated Users" (or other user group under which Visual Studio is running on your machine) from the "Permissions entries" list and click Edit ->
Check Deny for "Create files / write data" permission.
Click OK in all open dialogs and warnings to save changes.
Reopen Visual Studio and see it fail to do it's update.
Hope it helps.

In my case the issue was related to a missing bracket at the end of the file, so Visual Studio was being unable to process it, please check the JSON format is correct.

just check your launch settings file is a valid for JSON format, you should forget a comma or mustache

Related

launchsettings.json setting doesn't get pick up by visual studio automatically

When I create a new project using a custom Visual Studio template the launchSettings.json file isn't picked up automatically by Visual Studio and the same goes for all the rules which it is trying to impose, they aren't imposed.
To attach the launchSettings file one has to right click on the docker-compose.yml file and click on Manage Docker Compose Launch Settings then wait for the launchSettings file to load and click save.
This is how the docker-compose.yml file looks :
services:
services:
splunk:
image: splunk/splunk:latest
pgadmin:
image: dpage/pgadmin4
This is how the launchSettings.json file looks
{
"profiles": {
"First Profile": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"serviceActions": {
"pgadmin": "StartWithoutDebugging",
"splunk": "DoNotStart"
}
},
"Second Profile": {
"commandName": "DockerCompose",
"commandVersion": "1.0",
"serviceActions": {
"pgadmin": "StartWithoutDebugging",
"splunk": "StartWithoutDebugging",
}
}
}
}
Please advise how can the launchSettings.json file automatically picked up by the Visual Studio on the first launch without having to click on Manage Docker Compose Launch Settings.

Error occurring while trying to access an particulate page in Azure web app

I'm a newbie learner of ASP.NET. I was following along this ASP.NET Razor pages tutorial and deployed my app to Azure.
But when I'm trying to access this Movies page, I'm getting this error.
Error.
An error occurred while processing your request.
Request ID: | f9ecac03-478613f8cb88adc0.
Development Mode Swapping to the Development environment displays
detailed information about the error that occurred.
The Development environment shouldn't be enabled for deployed
applications. It can result in displaying sensitive information from
exceptions to end-users. For local debugging, enable the Development
environment by setting the ASPNETCORE_ENVIRONMENT environment variable
to Development and restarting the app.
I've tried this existing solution and changed the mode to production but the problem remained the same.
Here is my launch setting -
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50335",
"sslPort": 44327
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"Polling_System": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
}
}
My deployment mode was Framework-Dependent and later I changed it to Self-Contained.
Can anyone help me to resolve this problem? Thanks.
P.S. The page works properly on my machine if the value of "ASPNETCORE_ENVIRONMENT": is set to "Development"
Update:
This is the stanard webconfig:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\OurWebApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout">
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
Solution:
Add or change the ASPNETCORE_ENVIRONMENT setting of your web.config.
As the error says,
The Development environment shouldn't be enabled for deployed
applications.
So please change it to other env. I am sorry. Answered wrong just now.
Have look of this:
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-3.1#environments
Add these code in Web.config or change the value in webconfig.(under site/wwwroot on Kudu):
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="[Other env instead of Development]" />
</environmentVariables>
Your Kudu page should be: https://[yourwebsitename].scm.azurewebsites.net/DebugConsole
(Change the [yourwebsitename] to your website name and then you will go to kudu)
Don't forget to save the edit. This should work without restart.

App Search API Validation Tool displays "example.com is returning 469. Please check your url and try again."

I am online a fresh webpage for the purpose of universal links. I put the file in .well-known folder.
In the server log I can see that Applebot got 200 on "GET /.well-known/apple-app-site-association HTTP/1.1"
The only error displayed in the App Search API Validation Tool is:
"example.com is returning 469. Please check your url and try again."
I used another tool to check it - branch.io AASA Validator and it displays no errors.
Also make sure you don't have any robots.txt file in the root that disables Applebot
Robots.txt: allow only major SE
https://support.apple.com/en-us/HT204683
Looks like apple changed the format of AASA file. According to this official document, the old presentation
{
"applinks": {
"apps": [],
"details": [
{
"appID": "{PREFIX}.{BUNDLE_ID}",
"paths": ["*"]
}
]
}
}
Had already changed to:
{
"applinks": {
"details": [
{
"appIDs": [
"{PREFIX}.{BUNDLE_ID}"
],
"components": [
{
"/": "/*"
}
]
}
]
}
}
Considering backward compatibility, you can try writing in this format:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "{PREFIX}.{BUNDLE_ID}",
"paths": ["*"],
"appIDs": [
"{PREFIX}.{BUNDLE_ID}"
],
"components": [
{
"/": "/*"
}
]
}
]
}
}
This works for me, hope it helps.
What worked for me was adding image metadata on top of title and description metadata. I also added Touch icons, but I do not think it caused the issue since it works fine on another website I have without it.
Required metadata seems to be: Title, description and Image (og:image was the missing one in my case)
For metadata check out: The Open Graph Protocol
For icons check out: Developer Apple - Configuring Web Applications

How to create a bookmarks folder with javascript?

I'm looking at the MDN Javascript API example for bookmarks.create(). I'm trying to implement the example they have to learn how to make a folder:
function onBookmarkAdded(bookmarkItem) {
console.log("Bookmark added with ID: " + bookmarkItem.id);
}
chrome.bookmarks.create({
title: "bookmarks.create() on MDN",
url: "https://developer.mozilla.org/Add-ons/WebExtensions/API/bookmarks/create"
}, onBookmarkAdded);
This does nothing as far as I can tell. Any help or other examples of how to make a folder for bookmarks would be greatly appreciated.
Assuming you have added "bookmaks" to the permissions in your manifest.json file, then your code works as written to create a bookmark. Because your manifest.json file is not included in the question, we can not determine if that is the problem.
To create a bookmark folder, you either omit the url property or provide url:null in the object that you pass to bookmark.create()
Below is the complete, tested (on FF48.0.2 and Developer Edition, FF50.0a2), extension. It is wrapped in code that allows creating the bookmark when a browser_action button is clicked. I find it easier for testing to have things execute when a browser_action button is clicked rather than just on install/Firefox run. It will:
Create a bookmark titled and linked: bookmarks.create() on MDN
Create a bookmark folder My Bookmark Folder A
Create a bookmark folder My Bookmark Folder B
Create a bookmark folder My Bookmark Folder B.1 within My Bookmark Folder B
All of these are created under "Other Bookmarks" because no parentId is provided when calling bookmark.create() for any of them which are not children of a bookmark folder this extension creates.
background.js:
//* For testing, open the Browser Console
try{
//alert() is not supported in Firefox. This forces the Browser Console open.
// This abuse of a misfeature works in FF49.0b+, not in FF48
alert('Open the Browser Console.');
}catch(e){
//alert() throws an error in Firefox versions below 49
console.log('Alert() threw an error. Probably Firefox version below 49.');
}
//*
chrome.browserAction.onClicked.addListener(function(tab) {
doBrowserAction();
});
function doBrowserAction(){
console.log('Background: Doing action');
createABookmark();
createABookmarkFolder();
createABookmarkFolderWithinABookmarkFolder();
}
function onBookmarkAdded(bookmarkItem) {
console.log("Bookmark added with ID: " + bookmarkItem.id, bookmarkItem);
}
function createABookmark(){
chrome.bookmarks.create({
title: "bookmarks.create() on MDN",
url: "https://developer.mozilla.org/Add-ons/WebExtensions/API/bookmarks/create"
}, onBookmarkAdded);
}
function createABookmarkFolder(){
chrome.bookmarks.create({
title: "My Bookmark Folder A",
url: null
}, onBookmarkAdded);
}
function createABookmarkFolderWithinABookmarkFolder(){
chrome.bookmarks.create({
title: "My Bookmark Folder B",
url: null
}, bookmarkItem => {
onBookmarkAdded(bookmarkItem);
chrome.bookmarks.create({
title: "My Bookmark Folder B.1",
url: null,
parentId: bookmarkItem.id
},onBookmarkAdded
);
});
}
manifest.json:
{
"description": "Create a bookmark on browser_action button click",
"manifest_version": 2,
"name": "Demo: Create Bookmark",
"version": "0.1",
"applications": {
"gecko": {
//Firefox: must define id to use some features (e.g. option_ui)
"id": "demo-create-bookmark#example.com",
"strict_min_version": "48.0"
}
},
"permissions": [
"bookmarks"
],
"background": {
"scripts": [
"background.js"
]
},
"browser_action": {
"default_icon": {
"32": "myIcon.png"
},
"default_title": "Do Action",
"browser_style": true
}
}
Obviously, if you are going to use the various functions for more than a demo, you will want to make them more general purpose (i.e. passing callbacks, bookmark properties, etc.).
Note: Please see the section titled "General notes on testing and development of WebExtensions in Firefox" of this answer. Your statement, "This does nothing as far as I can tell", implies that you are not looking at the Browser Console for error messages or console logs.

grunt-contrib-watch : { tinylr: "Welcome", version: "0.0.4" }

I'm trying to get grunt working, with grunt-contrib-watch and grunt-contrib-compass.
So far, my Gruntfile looks like this:
module.exports = function (grunt){
grunt.initConfig({
compass : {
dist : {
options : {
debugInfo : 'true'
}
}
},
watch : {
files : ['*.html', 'js/*', 'sass/*'],
task : ['compass'],
options : {
livereload: true,
port : 35729
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch') ;
grunt.loadNpmTasks('grunt-contrib-compass') ;
grunt.registerTask('default', ['watch'])
} ;
I'm using chromes live-reload extension.
If I then run 'grunt -v', I can see that grunt watches my html and my sass files as expected. My browser tab reloads automatically, as expected.
In a browser tab I go to this address:
http://localhost:35729
However, in my browser I only see this upon loading and reloading:
{
tinylr: "Welcome",
version: "0.0.4"
}
I don't see my index.html. Just the object.
What do I need to do in order to see my site?
http://localhost:35729 is the address of the live reload server, not your website. Your website still needs to be served from it's own address/port, such as http://localhost:8000. Either through the grunt-contrib-connect task, some other node.js server or some server that serves files apache/nginx.
http://localhost:35729 is only used to load the live reload script into your page: <script src="http://localhost:35729/livereload.js"></script> and then upon changes will use a web socket to trigger and update your page on your website.
If you run with npm start, it will running on reload server.
So if you wanted to serve your website.
Try to use Multiplex

Resources