Base solution for your next web application

Activities of "jcompagnon"

No, my computer is hooked up via Ethernet and my phone is on LTE.

At first, I was under the impression that hooking up the smartphone via USB would connect it to the same network as the computer, especially since the emulator is running on LTE but is able to connect just fine. Based on your question and my recent tests though, that doesn't seem to be the case.

I've tried looking up the public IP of my network and putting that as the LocalhostIp, but that doesn't work either. Perhaps the easiest way around this would be to hook up my phone and computer to the same WiFi, but my office has a WiFi network that I cannot access. Otherwise I was looking into reverse usb tethering, but that seems to be quite a bit of work to accomplish.

Is this scenario something that should work or am I hitting my head against a wall for nothing?

Hi alirizaadiyahsi,

While running application with my device connected via USB, I tried opening a browser and going to the LocalhostIp set (by itself and with the port of the host :22742) but it was not able to connect.

I confirmed that there is nothing in place blocking the USB from extending connections to external devices and turned off all settings of the Windows Defender Firewall to make sure it wasn't that firewall blocking either.

Hello,

I am trying to run a .Mobile solution following this part of the documentation <a class="postlink" href="https://aspnetzero.com/Documents/Development-Guide-Xamarin#solution-structure-layers">https://aspnetzero.com/Documents/Develo ... ure-layers</a>.

I have set up the environment by setting the proper local IP to LocalhostIp in DebugServerIpAdresses.cs, downloaded the Xamarin Android SDK Manager and API up to 26 installed.

When debugging with the emulator Android_Accelerated_x86_Nougat (Android 7.1 - API 25), it brings up the emulator and runs the application correctly. I am able to sign in.

I've also hooked up my Android device via USB (Samsung Galaxy S7 - listed as Android 7.0 - API 24) and enabled USB debugging via Developer options. However, when I run the application again, it opens the splash screen on my phone but never moves from there, eventually getting an error saying "cannot connect to server".

I've confirmed that the AndroidManifest has INTERNET enabled as a Required permission.

Is there a setting I missed or some other add-on I need to download to make it work? Is it something to do with the solution or my Samsung device's settings?

Documentation I've already looked at: <a class="postlink" href="https://developer.xamarin.com/guides/android/getting_started/installation/windows/">https://developer.xamarin.com/guides/an ... n/windows/</a> <a class="postlink" href="https://developer.xamarin.com/guides/android/getting_started/installation/set_up_device_for_development/">https://developer.xamarin.com/guides/an ... velopment/</a> <a class="postlink" href="https://developer.xamarin.com/guides/android/troubleshooting/questions/android-internet/">https://developer.xamarin.com/guides/an ... -internet/</a>

Thanks!

Jonathan

Hello Alper!

Thanks for the suggestion. It does work when listed as its own site; my issue is that we're trying to have the app hosted under the same site as other projects - something like <a class="postlink" href="http://www.mydomain.com/">www.mydomain.com/</a>[project]. As we deal with many projects, we would like to keep this format consistent, if possible.

After publishing to a directory exposed through IIS, trying to run the app loads the login page - but all of the resources (script, style, images, etc) return 404s, since they're expecting the "view-resources", etc, to be available at the site root - rather than at /[project]/.

I was wondering if there was a central way to update what the app believed was site root, instead of having to update every reference to a resource.

Do you have any hints as to how I might accomplish this, or a direction in which I can look?

Hello,

According to the docs, the ApplicationPath has no setter; from the source, it looks like it's configured to return "/" by default. Should I just be creating a new Getter at this level, providing the project name we expect to see? Is that going to break other components?

Thank you for your help!

Hello!

I'm running into some issues trying to get an MVC/Jquery Core 2.0 project running under a default local IIS site, as all content requests are looking at the IIS base site (localhost:80/) instead of the virtual app underneath (localhost/MyApp/).

Is there a suggested way to update the links for "view-resources", etc, without updating all href/src tags in the app?

An update:

For now I've put the function in the AppServiceBase class in the application layer. I'm sure I'm breaking a whole lot of Best Practices, but as a rough draft / proof of concept:

public abstract class FirstASPNetZeroAppServiceBase : ApplicationService
    {
        private static readonly FirstASPNetZeroDbContext _dbContext = new FirstASPNetZeroDbContext();
        private static readonly object _dbContextLock = new object();

        protected FirstASPNetZeroDbContext DBContext
        {
            get
            {
                lock (_dbContextLock)
                {
                    return _dbContext;
                }
            }
        }
protected virtual List<Dictionary<string, object>> QueryDynamicData(string table, int entityID)
        {
            try
            {
                //Get the table desired based on the table name passed
                PropertyInfo dbSetInfo = DBContext.GetType().GetProperties().FirstOrDefault(p => p.Name.ToLower().Equals(table.ToLower()));

                //Return all results from the table into IQueryable set where Id = entityID passed
                IQueryable anyDbSet = ((IQueryable)dbSetInfo.GetValue(DBContext)).Where("Id=" + entityID);

                List<Dictionary<string,object>> listObjects = new List<Dictionary<String, Object>>();

                //Iterate through results
                foreach (Object entity in anyDbSet)
                {
                    //Create dictionary of Field Name, Field Value from results
                    Dictionary<string, object> listDBValues = entity.GetType().GetProperties().ToDictionary(propertyInfo => propertyInfo.Name, propertyInfo => propertyInfo.GetValue(entity));

                    //Add dictionary to list of dictionaries - useful for returning list of found results instead of just one
                    listObjects.Add(listDBValues);
                }

                //Return list of dictionaries
                return listObjects;
            }
            catch (Exception e) { }
            return null;
        }protected virtual List<Dictionary<string, object>> QueryDynamicData(string table, int entityID)
        {
            try
            {
                //Get the table desired based on the table name passed
                PropertyInfo dbSetInfo = DBContext.GetType().GetProperties().FirstOrDefault(p => p.Name.ToLower().Equals(table.ToLower()));

                //Return all results from the table into IQueryable set where Id = entityID passed
                IQueryable anyDbSet = ((IQueryable)dbSetInfo.GetValue(DBContext)).Where("Id=" + entityID);

                List<Dictionary<string,object>> listObjects = new List<Dictionary<String, Object>>();

                //Iterate through results
                foreach (Object entity in anyDbSet)
                {
                    //Create dictionary of Field Name, Field Value from results
                    Dictionary<string, object> listDBValues = entity.GetType().GetProperties().ToDictionary(propertyInfo => propertyInfo.Name, propertyInfo => propertyInfo.GetValue(entity));

                    //Add dictionary to list of dictionaries - useful for returning list of found results instead of just one
                    listObjects.Add(listDBValues);
                }

                //Return list of dictionaries
                return listObjects;
            }
            catch (Exception e) { }
            return null;
        }

I posted the question on Stack Overflow and got some good answers. <a class="postlink" href="https://stackoverflow.com/questions/46285519/query-an-entity-framework-entity-without-knowing-the-object-type-class-table-i">https://stackoverflow.com/questions/462 ... ss-table-i</a>

I'm wondering now where would I put such a function?

I've tried adding it to the ProjectRepositoryBase.cs where it says to add common methods:

public abstract class FirstASPNetZeroRepositoryBase<TEntity, TPrimaryKey> : EfRepositoryBase<FirstASPNetZeroDbContext, TEntity, TPrimaryKey>
        where TEntity : class, IEntity<TPrimaryKey>
    {
        protected FirstASPNetZeroRepositoryBase(IDbContextProvider<FirstASPNetZeroDbContext> dbContextProvider)
            : base(dbContextProvider)
        {

        }

        //add your common methods for all repositories
        public object[] QueryDynamicData(string table, int entityID)
        {
            try
            {
                
            }catch(Exception e) { }
            return null;
        }
    }

However, when I go to an AppService class, I cannot access that method from the repository (_patientRepository will not find method QueryDyanmicData() from above)

public class PatientAppService : FirstASPNetZeroAppServiceBase, IPatientAppService
    {
        private readonly IRepository<PatientItem> _patientRepository;

        public PatientAppService(IRepository<PatientItem> patientRepository)
        {
            _patientRepository = patientRepository;
        }

        public async Task<PagedResultDto<PatientListDto>> GetPatientsForGrid(GetPatientsInput input)
        {
            _patientRepository
//...other code

Thanks!

I have done some googling, but nothing useful so far has come up. I've posted a question on Stack Overflow, we'll see if anything comes of it.

Thanks for your input!

Hello,

I'm wondering, if it's possible in the first place, how I would go about querying the database (using EF) using an ID and a table name.

For example:

QueryDynamicData(string tableName, long entityID){
return GetItem(tableName, entityID);
}

And could be called like:

var entry = QueryDynamicData("Person", 143);

Thanks in advance!

Showing 11 to 20 of 39 entries