Base solution for your next web application

Activities of "dparizek"

Using ASP.NET Core & Angular latest version 9.1.0, with Power Tools version 2.6.1

In Visual Studio 2019, go to Tools->Asp.netZero->Create Entity

Go to Add New Navigation Property

Under Select Your Entity choose BinaryObject {project.Storage} Guid

Then under Display Property there are no choices available, and you cannot select OK because then it asks you to choose a Display Property.

Where is the recommended place to submit feature requests? Here or GitHub issues? or where?

Thanks!

I have an automatic UoW that is failing based on checking thus:

_unitOfWorkManager.Current.Failed += (sender, args) => { Debug.WriteLine("UoW Failed"); };

How would I go about debugging that - ultimately I get a 500 error back on the Angular side but how do I debug why the transaction if failing?

Any advice appreciated!!!

Hi:

Just wondering about the new Webhook feature in latest new release... where should I go to read more about it?

I want to use this spinner control from Metronic in Angular 1 solution: http://keenthemes.com/preview/metronic/theme/admin_4/ui_buttons_spinner.html

So I have this in my .cshtml:

  <button type="button"  ng-click="vm.delete()" class="btn btn-success mt-ladda-btn ladda-button" data-style="expand-up" data-size="l">
            <span class="ladda-label">Delete Only</span>
            <span class="ladda-spinner"></span><div class="ladda-progress" style="width: 0px;"></div>
   </button>

and do I need to add scripts for Ladda or would they already be included with Metronic scripts? Best practice place/folder in project to add them if necessary?

https://github.com/msurguy/ladda-bootstrap

And best practice usage in Angular? Metronic only gives the markup.

Basically I am looking for some direction on best approach to using the Metronic components in general in Angular ASP.NET ZERO.

Any guide or suggestions?

I am trying to disable antiforgery at least temporarily so that I can use Telerik Reporting and it will not pass the antiforgery cookie:

@{ SetAntiForgeryCookie(); }

I can see cookie in browser console but Telerik not passing it and also Telerik talks of enabling Cors.

When I add:

Configuration.Modules.AbpWeb().AntiForgery.IsEnabled = false;

to my ApplicationModule PreInitialize method then I am missing a Using statement as it does not recognize AbpWeb()

What would be the Using statement? I tried using Abp.Configuration.Startup; no luck.

Also, I cannot find any EnableCores function in my codebase... where does that go if I want to enable Cors?

The following code works great in a .NET framework 4.6-4.6.2 console app, but will not work when I bring it into the Angular1/MVC version of ASP.NET Zero...

      `  string xmldata = "<records><item><record>";
        xmldata += ptid;
        xmldata += "</record><field_name>";
        xmldata += fieldname;
        xmldata += "</field_name><value>" + newvalue + "</value><redcap_event_name>";
        xmldata += redcap_event_name;
        xmldata += "</redcap_event_name></item></records>";

        var sbPostData = new StringBuilder();
        sbPostData.Append("token=" + token);
        sbPostData.Append("&content=record");
        sbPostData.Append("&format=xml");
        sbPostData.Append("&type=eav");
        sbPostData.Append("&overwriteBehavior=normal");
        sbPostData.Append("&data=" + xmldata);
        sbPostData.Append("&returnContent=ids");
        sbPostData.Append("&returnFormat=xml");

        var byteArray = Encoding.UTF8.GetBytes(sbPostData.ToString());

        string Baseurl = "https://redcap.uahs.arizona.edu/api/";
        Uri REDCapUri = new Uri(Baseurl);

        var webRequest = WebRequest.CreateHttp(REDCapUri);
        webRequest.Method = "POST";
        webRequest.ContentType = "application/x-www-form-urlencoded";

        try
        {
            webRequest.GetRequestStream().WriteAsync(byteArray, 0, byteArray.Length);
            var webResponse = webRequest.GetResponse();
            return "success";
        }
        catch (Exception e)
        {
            Debug.WriteLine(String.Concat(e.Message, e.StackTrace));
            return e.Message;
        }`
        

At this line: var webResponse = webRequest.GetResponse();

I get this error returned:

Exception thrown: 'System.Net.WebException' in System.dll The underlying connection was closed: An unexpected error occurred on a send. at System.Net.HttpWebRequest.GetResponse()

Why might it work in the console app but not within ASP.NET Zero framework? Any hints what I might try?

With the newer Core versions of ASP.NET Zero if you want to have non-login landing pages for your SaaS product you now need to use a multi-domain approach. Why this approach? I cannot think of any SaaS businesses out there where their business is divided up into multiple domains. I want to brand only one domain name, and have only one domain name. I don't want my landing pages/business information/sales pages on one domain name, and then my SPA on another domain name... that makes no sense to me and could confuse my customers. Are there any examples of SaaS businesses structured that way out there? I have never seen any such examples.

Can anyone suggest what steps are required to put things back to customer arrives at mydomain.com, can visit About page and Home page and learn about my Saas, and sign up, and then login to SPA that is maybe at mydomain.com/myspa, and I don't need to redirect them to myseconddomain.com for the SPA??

Sharing this in case it helps... how I set up to use ASP.NET Zero on my mac (macOs High Sierra)...

Running ASP.NET Zero on Mac

Install Visual Studio for Mac: <a class="postlink" href="https://www.microsoft.com/net/download/macos">https://www.microsoft.com/net/download/macos</a> Install Visual Studio Code: <a class="postlink" href="https://code.visualstudio.com/">https://code.visualstudio.com/</a> Install .net core SDK: <a class="postlink" href="https://www.microsoft.com/net/download/macos">https://www.microsoft.com/net/download/macos</a>

From ASP.Net Zero download the ASP.NET CORE & Angular latest project version (5.4.1 at this writing) with .NET Core 2.0 as chosen framework and do not check one solution.

In the terminal, go to base_folder/angular and

yarn

(after installing latest: • yarn, in my case version 1.6.0 (<a class="postlink" href="https://yarnpkg.com/lang/en/docs/install/#mac-stable">https://yarnpkg.com/lang/en/docs/install/#mac-stable</a>, I used HomeBrew) • and I use nvm with node version 8.11.1 (<a class="postlink" href="https://github.com/creationix/nvm">https://github.com/creationix/nvm</a> • and angular cli (<a class="postlink" href="https://cli.angular.io/">https://cli.angular.io/</a>)

Next we open app in Visual Studio for Mac. For starters, I opened the Web solution only, under base_folder/aspnet-core

Set Web.Host project as Startup Project (right click on Web.Host project in Solution Explorer and you will see the option)

Build all.

I used a SQL database on Azure, set up in Azure Portal, and there got connection string like this, into base_folder/ aspnet-core/appsettings.json:

"ConnectionStrings": {
	      "Default": "Server=tcp:research1server.database.windows.net,1433;Initial Catalog={my db name};Persist Security Info=False;User ID={my_id};Password={my password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"},

Note you have to get your IPv4 address (e.g. <a class="postlink" href="https://www.whatismyip.com/">https://www.whatismyip.com/</a>) and in Azure Portal click on your database, then the "Set server firewall" button, then create a rule for your IP address (or range of addresses) and Save. Otherwise when you start-up you will see a Connection Refused error in the browser console.

Next we open app in Visual Studio for Mac. For starters, I opened the Web Solution only, under base_folder/aspnet-core

Set Web.Host project as Startup Project (right click on Web.Host project in Solution Explorer and you will see the option)

Now we want to get EF for dotnet. Initially, I used my window machine to do the first database update/migration/initialization on the Azure database instance. But now exploring how to do on Mac:

Go here: <a class="postlink" href="https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/dotnet">https://docs.microsoft.com/en-us/ef/cor ... cli/dotnet</a> and see Installing the Tools section.

Edit the Web.Host project file (right click project name and there is an Edit File option) and add following:
<ItemGroup> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" /> </ItemGroup>

Then back in Terminal:

dotnet add package Microsoft.EntityFrameworkCore.Design 
	dotnet restore

Check your dotnet ef install:

dotnet ef

And you should see a nice ascii unicorn:

Run the project in Visual Studio for Mac, it should take you to <a class="postlink" href="http://localhost:5000/swagger/">http://localhost:5000/swagger/</a> and that worked for me.

Then go to base_folder/angular and:

npm start

Wait, then navigate in browser to <a class="postlink" href="http://localhost:4200/">http://localhost:4200/</a>

And first it did not work for me because I had to set up the firewall rule for Azure, as above.

Then it did not work for me because the client side, according to the browser console, was trying to go to port 22742. But my server side was going to 5000 even though I did not set that anywhere, and appsettings.json seemed to only refer to 22742.

So using Visual Studio Code, I searched the angular project and replaced all instances of 22742 with 5000.

Then… it finally worked! (-:

There is no Package Manager Console in Visual Studio for Mac, so in Terminal you can Add-Migration:

dotnet ef migrations add InitialCreate

Or Update-Database:

dotnet ef database update

When you need to update service-proxies.ts then from angular directory after/while Web.Host project is up and running:

./node_modules/.bin/nswag run

For RAD tool on Mac, there is no Visual Studio extension to create the JSON input file, you create it manually. Which can be faster actually than field by field in GUI. Then run:

dotnet AspNetZeroRadTool.dll YourEntity.Json

(from <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide-Rad-Tool-Mac-Linux">https://aspnetzero.com/Documents/Develo ... -Mac-Linux</a>)

If you want to use VS Code on Mac without Visual Studio Mac, this is useful to set Startup Project... <a class="postlink" href="https://stackoverflow.com/questions/46705521/how-do-i-designate-a-startup-project-in-vs-code">https://stackoverflow.com/questions/467 ... in-vs-code</a>

Feature Request - where should we submit these?

for the RAD Tool it would be nice if permissions were grouped under the NameSpace chosen... so when viewing permissions each permission set (generated for an entity) would be nested under the NameSpace like for example how Settings and Organizational Units permissions are nested under Administration

Latest rendition of the tool is GREAT - Thanks ANZ team!

Showing 1 to 10 of 29 entries