I am trying to get my ASP.Net 5 MVC6 website to run on IIS Express 10 and it keeps giving me a an error which says:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
(Image Attached for full error)
I have successfully run the website from within Visual Studio 2015 Community but I want an 'Always on' solution so I don't have to keep starting and stopping the website from within VS.
I have the following in the IISExpress/config/applicationhost.config file:
<sites>
<site name="Admin" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\Users\Admin\Documents\Visual Studio 2015\Projects\CMS\src\Admin\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":12345:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
The URL I am using is: http://localhost:12345/
I have the following in my web.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600" forwardWindowsAuthToken="true" />
</system.webServer>
</configuration>
And my project.json file
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.FileProviderExtensions" : "1.0.0-rc1-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
],
"scripts": {
"prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ]
}
}
I had the same problem with Azure Web App. I managed to fix it by removing startupTimeLimit and forwardWindowsAuthToken properties from web.config httpPlatform tag. I found the solution by comparing my project to working one. Don't know if removal of properties have some side effects.
Related
I tried to fetch api from laravel server in my react native app
I launched laravel servers with php artisan serve --host=0.0.0.0 so i can access to my api route with http://myIp:8000/myProject/api/; in this project i have route
Route::get('/test', function(){
return response()->json([
'data' => 'test'
]);
});
I already tested http://myIp:8000/myProject/api/test in my mobiles device's browser and i got the json data;
So in my react native i installed axios configured like this:
axios.create({
baseUrl: base_url_api,
headers: {
Accept: 'application/json',
'Content-type': 'application/json'
}
})
And i fetch the api like this axios.get("http://myIp:8000/myProject/api/test") but it throw error Error Network;
So i tried with axios.get("https://jsonplaceholder.typicode.com/todos/1") and i got the json data from jsonplaceholder;
I already set android:usesCleartextTraffic="true" on my AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.test">
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MainApplication"
android:label="#string/app_name"
android:icon="#mipmap/ic_launcher"
android:roundIcon="#mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="#style/AppTheme"
android:usesCleartextTraffic="true"
>
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:launchMode="singleTask"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
but it not work;
here my package.json dependecies
"dependencies": {
"axios": "^0.21.4",
"react": "17.0.2",
"react-native": "0.65.1",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "^1.10.3",
"react-native-paper": "^4.9.2",
"react-native-reanimated": "^2.2.2",
"react-native-safe-area-context": "^3.3.2",
"react-native-screens": "^3.7.2",
"react-native-vector-icons": "^8.1.0"
},
"devDependencies": {
"#babel/core": "^7.15.5",
"#babel/runtime": "^7.15.4",
"#react-native-community/eslint-config": "^3.0.1",
"babel-jest": "^27.2.2",
"eslint": "^7.32.0",
"jest": "^27.2.2",
"metro-react-native-babel-preset": "^0.66.2",
"react-native-codegen": "^0.0.7",
"react-test-renderer": "17.0.2"
},
my react native cli version
react-native --version
react-native-cli: 2.0.1
react-native: 0.65.1
I know it's stupid but I used wrong properties name for axios configuration,
instead baseURL I set baseUrl
axios.create({
baseURL: base_url_api,
headers: {
Accept: 'application/json',
'Content-type': 'application/json'
}
})
Posted on behalf of the question asker
With localhost Angular PWA service worker works fine in all scenarios, BUT After deployment (on Azure server with GIT pipeline), In Online mode all works fine: 1. Service Worker is registered. 2. API responses are cached. Now when i go offline, the service worker still tries to fetch the api response from Network( and give 504 error since its offline mode) INSTEAD of taking those responses from CACHE. I can see the data there in cache, But the problem is that ServiceWorker still tries to fetch it from network only, even in offline mode.
ngsw-config.json
{
"$schema": "./node_modules/#angular/service-worker/config/schema.json",
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/manifest.webmanifest",
"/*.css",
"/*.js"
],
"urls": [
"https://fonts.googleapis.com/css?family=Roboto:400,700",
"https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap",
"https://fonts.gstatic.com/s/",
"https://fonts.googleapis.com/icon?family=Material+Icons",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
],
"dataGroups": [
{
"name": "api-performance",
"urls": [
"https://api***************.com/fuzzy",
"https://api*********************.com/kdks"
],
"cacheConfig": {
"strategy": "performance",
"maxSize": 100,
"maxAge": "3d"
}
},
{
"name": "api-freshness",
"urls": [
"https://pwa***********************.com/TS_LIST",
"https://ap***********************.com/ores/",
"https://as*************************.com/ands/"
],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 200,
"maxAge": "1h",
"timeout": "10s"
}
}
]
}
for deployment build i run following commands:
ng build --prod
and then the build files generated in dist folder are pushed to GIT repo in deploy branch, from there with git pipeline it is automatically deployed to the Azure server. Some GIT answers suggest to remove the "$schema" tag from ngsw-config.json file which i have tried still the issue persists.
Kindly Help. Thanks in Advance.
Issue that i faced was, After deployment on Azure, Angular PWA service worker does not fetch the api response from cache in Offline mode, and also the manifest created was showing error in deployed version, whereas in localhost it was all working perfect.
the main issue for me was: By default, IIS does not serve any files that does not have a MIME map associated with it in its (IIS) core settings.
To address this challenge, you will need to map the .webmanifest file extension to its appropriate MIME type.
For this you need to add following to web.config file:
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
</staticContent>
this helps azure to understand our manifest.webmanifest file which otherwise it will not be able to. After this it was able to detect manifest.webmanifest file which solved my both issues, Fetching the response from cache in Offline mode, And also with manifest file now my Angular PWA app was installable with app icon and all other features. Many other GIThub answers were suggesting to change scope and start_url parameters in manifest file but i kept it what was there by default
In manifest.webmanifest
"scope": "./",
"start_url": "./",
Also just For reference the full code for my web.config file is
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Redirect to https" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
<staticContent>
<mimeMap fileExtension=".json" mimeType="application/json" />
<mimeMap fileExtension=".webmanifest" mimeType="application/manifest+json" />
</staticContent>
</system.webServer>
</configuration>
I am creating a nativescript application and when I try to debug on my android device (connected via usb) the app opens the splash screen and immediately crashes without any errors shown in the console.
I open another terminal and use adb logcat *:W --pid=15820 to get error output (warnings and above) and all I see is failures to connect. These occur after the app crashes and keep repeating every second. What else can I do to find out why my app is crashing? It runs fine on an ios emulator.
06-29 15:45:30.127 15820 15820 E adbd : failed to connect to socket 'localabstract:com.mycompany.myapp-livesync': Connection refused
06-29 15:45:31.136 15820 15820 E adbd : failed to connect to socket 'localabstract:com.mycompany.myapp-livesync': Connection refused
06-29 15:45:32.141 15820 15820 E adbd : failed to connect to socket 'localabstract:com.mycompany.myapp-livesync': Connection refused
package.json
{
"nativescript": {
"id": "com.mycompany.myapp",
"tns-ios": {
"version": "5.4.2"
},
"tns-android": {
"version": "5.4.0"
}
},
"description": "My Mobile App",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "https://github.com/...",
"scripts": {
"lint": "tslint \"src/**/*.ts\"",
"clean": "find ./src -name '*.js' -delete",
"debug:android": "adb logcat *:W --pid=15820"
},
"dependencies": {
"#angular/animations": "8.0.0",
"#angular/common": "8.0.0",
"#angular/compiler": "8.0.0",
"#angular/core": "8.0.0",
"#angular/forms": "8.0.0",
"#angular/http": "8.0.0-beta.10",
"#angular/platform-browser": "8.0.0",
"#angular/platform-browser-dynamic": "8.0.0",
"#angular/router": "8.0.0",
"#ngxs/store": "^3.4.3",
"#turf/bearing": "^6.0.1",
"#turf/distance": "^6.0.1",
"nativescript-angular": "^8.0.0",
"nativescript-camera": "^4.5.0",
"nativescript-geolocation": "5.1.0",
"nativescript-google-maps-sdk": "2.7.0",
"nativescript-plugin-firebase": "^9.0.1",
"nativescript-social-share": "^1.5.2",
"nativescript-theme-core": "1.0.4",
"nativescript-urlhandler": "1.2.3",
"reflect-metadata": "0.1.13",
"rxjs": "6.5.2",
"tns-core-modules": "^5.4.3",
"zone.js": "^0.8.4"
},
"devDependencies": {
"#angular/compiler-cli": "8.0.0",
"#ngtools/webpack": "8.0.3",
"nativescript-dev-typescript": "^0.10.0",
"nativescript-dev-webpack": "0.24.1"
},
"readme": "My App"
}
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="__PACKAGE__"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="com.mycompany.myapp"
android:allowBackup="true"
android:icon="#drawable/icon"
android:label="My Mobile App"
android:theme="#style/AppTheme">
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
<meta-data android:name="firebase_analytics_collection_enabled" android:value="false" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="#string/nativescript_google_maps_api_key" />
<activity
android:name="com.tns.NativeScriptActivity"
android:label="#string/title_activity_kimera"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/LaunchScreenTheme"
android:launchMode="singleTask">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="#style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="veganbeacon" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
Looking through logcat in Android Studio gave me some addition error output:
2019-06-30 07:58:56.785 10645-10645/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mycompany.myapp, PID: 10645
java.lang.RuntimeException: Unable to instantiate application com.mycompany.myapp: java.lang.ClassNotFoundException: Didn't find class "com.mycompany.myapp" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-rkxokotTtXOg1zrVZvRGdg==/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-rkxokotTtXOg1zrVZvRGdg==/lib/x86, /data/app/com.mycompany.myapp-rkxokotTtXOg1zrVZvRGdg==/base.apk!/lib/x86, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:1069)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5842)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.mycompany.myapp" on path: DexPathList[[zip file "/data/app/com.mycompany.myapp-rkxokotTtXOg1zrVZvRGdg==/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.myapp-rkxokotTtXOg1zrVZvRGdg==/lib/x86, /data/app/com.mycompany.myapp-rkxokotTtXOg1zrVZvRGdg==/base.apk!/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
at android.support.v4.app.CoreComponentFactory.instantiateApplication(CoreComponentFactory.java:49)
at android.app.Instrumentation.newApplication(Instrumentation.java:1120)
at android.app.LoadedApk.makeApplication(LoadedApk.java:1061)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5842)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
I think you had modified
<application
android:name="com.tns.NativeScriptApplication"
to
<application
android:name="com.mycompany.myapp"
You may do it only if you are extending your own custom application class.
I have an app written in Keno UI (Telerik). I'm using build.phonegap.com to build runtime for my app, using cordova and Kendo. I'm stuck on getting the speechrecognition plugin to initialize. I'm sure it's something stupid but I'm not sure what it is.
Below is a copy of my config.xml file:
<?xml version='1.0' encoding='utf-8'?>
<widget id="ca.xyz.mmb" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>mmb</name>
<description>
Integrated Mobile Billing for XYZ Customers
</description>
<author email="support#xyz.ca" href="http://xyz.ca">
Go Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-compat" spec="^1.2.0" />
<plugin name="cordova-plugin-file" spec="^4.3.3" />
<plugin name="cordova-plugin-speechrecognition" spec="1.2.0" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="ios" spec="^4.3.1" />
</widget>
Below is a copy of the relevant portion of the build:
Build Date: 2018-10-16 05:38:36 +0000
--------------------------------------------------------------------------------
PLUGIN OUTPUT
--------------------------------------------------------------------------------
Fetching plugin "cordova-plugin-compat#^1.2.0" via npm
Installing "cordova-plugin-compat" at "1.2.0" for android
Fetching plugin "cordova-plugin-file#^4.3.3" via npm
Installing "cordova-plugin-file" at "4.3.3" for android
Plugin dependency "cordova-plugin-compat#1.2.0" already fetched, using that version.
Dependent plugin "cordova-plugin-compat" already installed on android.
The Android Persistent storage location now defaults to "Internal".
Please check this plugin's README to see if your application needs any changes in its config.xml.
If this is a new application no changes are required.
If this is an update to an existing application that did not specify an "AndroidPersistentFileLocation" you may need to add:
"<preference name="AndroidPersistentFileLocation" value="Compatibility" />"
to config.xml in order for the application to find previously stored files.
Fetching plugin "cordova-plugin-speechrecognition#1.2.0" via npm
Installing "cordova-plugin-speechrecognition" at "1.1.2" for android
--------------------------------------------------------------------------------
PROJECT PROPERTIES
Below is the initalization code for the program.
(function () {
var bootstrap = function () {
$(function () {
alert("running bootstrap");
app.mobileApp = new kendo.mobile.Application(document.body, {
transition: 'slide',
skin: 'flat',
initial: 'components/home/view.html',
statusBarStyle: 'black-translucent',
layout: 'main'
});
alert("speech init "); //this is the last alert that pops up
window.plugins.speechRecognition.isRecognitionAvailable(
function(result) {
useSpeech = result ; alert("speech");
},
function(err) {
useSpeech = false; alert(err);
}
);
alert("done speech init");
});
};
bootstrap();
The place where I try to run isRecognitionAvailable is where it fails. I'm not sure why. I've tried putting in an alert for window.plugins just to see what it says but that always comes back undefined. A search on google implies that that is normal, so that doesn't help me much.
I'm having trouble in one project handling actions from AdaptiveCards. My method works perfectly fine in all my other projects, just not the most recent. I tried rolling back the version of bot.builder and bot.connector to match the other projects but that didn't help.
The card displays fine but as soon as you hit the button you get the good old "Sorry, my bot code is having an issue". I am displaying the card in the RootDialog, and calling context.wait(MessageReceivedAsync)
Debugging, if I type something to the bot after the card has been displayed MessageReceivedAsync gets fired. Clicking the button, never gets there. Putting a break point directly in the MessageController it gets there, but stepping into it just dies immediately and shows "Sory, my bot code is having an issue."
Here is my MessageController:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
await Conversation.SendAsync(activity, () => new RootDialog());
}
Here is the adaptive card action:
"actions": [
{
"type": "Action.Submit",
"title": "Create On-Line Request",
"data": {
"action": "requestContact"
}
}
]
}
In my RootDialog:
await context.PostAsync(CardHelper.MakeCard(context, "~\\AdaptiveCards\\ContactInfo311.json", replacements));
context.Wait(MessageReceivedAsync);
The card displays fine but as soon as you hit the button you get the good old "Sorry, my bot code is having an issue".
I do a test with the following sample code, which works for me, you can refer to it. And if possible, you can test it on your side to check if it works for you.
In RootDialog:
[Serializable]
public class RootDialog : IDialog<object>
{
public Task StartAsync(IDialogContext context)
{
context.Wait(MessageReceivedAsync);
return Task.CompletedTask;
}
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
var activity = await result as Activity;
var replymes = context.MakeMessage();
if (activity.Text != null)
{
if (activity.Text.ToLower().Contains("cards"))
{
replymes = context.MakeMessage();
var cardjson = await GetCardText("ContactInfo311");
var results = AdaptiveCard.FromJson(cardjson);
var card = results.Card;
replymes.Attachments.Add(new Attachment()
{
Content = card,
ContentType = AdaptiveCard.ContentType,
Name = "Card"
});
}
else
{
replymes.Text = $"You sent {activity.Text}";
}
}
else if (activity.Value != null)
{
replymes.Text = $"submit data: {activity.Value}";
}
// return our reply to the user
await context.PostAsync(replymes);
context.Wait(MessageReceivedAsync);
}
public async Task<string> GetCardText(string cardName)
{
var path = System.Web.HttpContext.Current.Server.MapPath($"~/AdaptiveCards/{cardName}.json");
if (!File.Exists(path))
return string.Empty;
using (var f = File.OpenText(path))
{
return await f.ReadToEndAsync();
}
}
}
ContactInfo311.json
{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"size": "large",
"weight": "bolder",
"text": "This is Adaptive Card"
}
],
"actions": [
{
"type": "Action.Submit",
"data": {
"action": "requestContact"
},
"title": "Clike me"
}
]
}
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AdaptiveCards" version="1.0.0" targetFramework="net46" />
<package id="Autofac" version="3.5.2" targetFramework="net46" />
<package id="Chronic.Signed" version="0.3.2" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net46" />
<package id="Microsoft.Bot.Builder" version="3.15.2.2" targetFramework="net46" />
<package id="Microsoft.Bot.Connector" version="3.15.2.2" targetFramework="net46" />
<package id="Microsoft.CSharp" version="4.4.0" targetFramework="net46" />
<package id="Microsoft.IdentityModel.Logging" version="1.1.4" targetFramework="net46" />
<package id="Microsoft.IdentityModel.Protocol.Extensions" version="1.0.4.403061554" targetFramework="net46" />
<package id="Microsoft.IdentityModel.Protocols" version="2.1.4" targetFramework="net46" />
<package id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="2.1.4" targetFramework="net46" />
<package id="Microsoft.IdentityModel.Tokens" version="5.1.4" targetFramework="net46" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.2" targetFramework="net46" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.1.0" targetFramework="net46" />
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="net46" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.1.4" targetFramework="net46" />
</packages>
Test Result:
Besides, to troubleshoot the issue with your project, you can set breakpoint and debug the code step by step to trace the activity and check if the error is caused by activity.Text=null.