Kukuba008
Kukuba008
CC#
Created by Kukuba008 on 4/20/2023 in #help
❔ URL generating in MVC
Hello i need help with error that occurs when I'm generating URLs in ASP.NET MVC .NET Framework 4.6.2 application. When URL is generated in 'a' tag using '@Url.Action("Index")?TK=4' it works -> outputs '/folder/controller/index?TK=4'.
<a class="dropdown-item" href="@Url.Action("Index")?TK=4">xxx</a>
<a class="dropdown-item" href="@Url.Action("Index")?TK=4">xxx</a>
But when the URL is passed in parameter to JS function, that does something and then redirects to that URL it will generate the URL wrong -> it generates '/controller/index?TK=4'. It is missing the '/folder/' at the start.
<a class="dropdown-item" href="javascript:DownloadExport('@Url.Action("index")?TK=4');">Excel XLSX</a>
<a class="dropdown-item" href="javascript:DownloadExport('@Url.Action("index")?TK=4');">Excel XLSX</a>
or just starting in the JS function:
$('#View').on('change', function () {
window.location = '@Url.Action("Index")?TK=4';
});
$('#View').on('change', function () {
window.location = '@Url.Action("Index")?TK=4';
});
So: 1) How can I generate it properly in JS ? 2) And what can be wrong with it ? Note: All these pieces of code works well localy and on test (generates the URL with '/folder/'), but it doesn't work on production (doesnt generate '/folder/'), even though there is the same code. So the mistake might be in configuration ?
2 replies
CC#
Created by Kukuba008 on 1/21/2023 in #help
❔ Graph Api - load Events
2 replies
CC#
Created by Kukuba008 on 1/15/2023 in #help
✅ Microsoft Graph API
Hello I need to create program that will load data from Outlook calendar, which is done using Microsoft Graph API, so i have this code:
var scopes = new[] { "https://graph.microsoft.com/.default" };

// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "teanantid";

// Values from app registration
var clientId = "clientid";
var clientSecret = "clientsecret";

// using Azure.Identity;
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};

// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret, options);

var graphClient = new GraphServiceClient(clientSecretCredential, scopes);


var x = await graphClient.Users["clientid"].Request().GetAsync();
var scopes = new[] { "https://graph.microsoft.com/.default" };

// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "teanantid";

// Values from app registration
var clientId = "clientid";
var clientSecret = "clientsecret";

// using Azure.Identity;
var options = new TokenCredentialOptions
{
AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
};

// https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential
var clientSecretCredential = new ClientSecretCredential(
tenantId, clientId, clientSecret, options);

var graphClient = new GraphServiceClient(clientSecretCredential, scopes);


var x = await graphClient.Users["clientid"].Request().GetAsync();
Got from here: https://learn.microsoft.com/en-us/graph/sdks/choose-authentication-providers?tabs=CS#client-credentials-provider But im getting this error:
Code: Authorization_RequestDenied
Message: Insufficient privileges to complete the operation.
Code: Authorization_RequestDenied
Message: Insufficient privileges to complete the operation.
*All the variables are filled properly, i just deleted the values here. What should i do ? Thanks
20 replies
CC#
Created by Kukuba008 on 11/5/2022 in #help
Nested array in DataGridView
Hello, i want to display object in DataGridView (WinForms) that has an array of values (plus some normal properties) and each value should be assigned to new column, how can i do it ? Example: class:
string Name = "name" //some normal properties (easy to do normaly)
string[] items = new string[] {"a", "b", "c"} //array of items (amount vary every time, but all object have same amount of items)
string Name = "name" //some normal properties (easy to do normaly)
string[] items = new string[] {"a", "b", "c"} //array of items (amount vary every time, but all object have same amount of items)
which turns into one line in grid "name", "a", "b", "c" I know how to dynamicaly create columns, but i don't know how to bind array to it. I would need something like: column.DataPropertyName = "items[0]";
Thanks
2 replies